commit b59998eb5b9c4e6e142b530604539c54028acb8d (HEAD, refs/remotes/origin/master) Author: Glenn Morris Date: Mon Nov 17 23:59:44 2014 -0800 Use automatic variables in nt/Makefile.in * nt/Makefile.in (addpm${EXEEXT}, ddeclient${EXEEXT}) (cmdproxy${EXEEXT}, runemacs${EXEEXT}, emacs.res): Use automatic variables. diff --git a/nt/ChangeLog b/nt/ChangeLog index 2d0df9d..457d97c 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,9 @@ +2014-11-18 Glenn Morris + + * Makefile.in (addpm${EXEEXT}, ddeclient${EXEEXT}) + (cmdproxy${EXEEXT}, runemacs${EXEEXT}, emacs.res): + Use automatic variables. + 2014-10-26 Dani Moncayo * README.W32 (Preliminaries): Don't assume that this file is at diff --git a/nt/Makefile.in b/nt/Makefile.in index be5bae5..63bef28 100644 --- a/nt/Makefile.in +++ b/nt/Makefile.in @@ -214,17 +214,16 @@ TAGS: ${EXE_FILES:${EXEEXT}=.c} ## Build the programs addpm${EXEEXT}: ${srcdir}/addpm.c ../src/epaths.h - $(CC) ${ALL_CFLAGS} ${srcdir}/addpm.c $(LIBS_ADDPM) -o addpm${EXEEXT} + $(CC) ${ALL_CFLAGS} $< $(LIBS_ADDPM) -o $@ ddeclient${EXEEXT}: ${srcdir}/ddeclient.c - $(CC) ${ALL_CFLAGS} ${srcdir}/ddeclient.c -o ddeclient${EXEEXT} + $(CC) ${ALL_CFLAGS} $< -o $@ cmdproxy${EXEEXT}: ${srcdir}/cmdproxy.c - $(CC) ${ALL_CFLAGS} ${srcdir}/cmdproxy.c -o cmdproxy${EXEEXT} + $(CC) ${ALL_CFLAGS} $< -o $@ runemacs${EXEEXT}: ${srcdir}/runemacs.c $(EMACSRES) - $(CC) ${ALL_CFLAGS} ${srcdir}/runemacs.c $(EMACSRES) -mwindows \ - -o runemacs${EXEEXT} + $(CC) ${ALL_CFLAGS} $^ -mwindows -o $@ emacs.res: ${srcdir}/emacs.rc ${srcdir}/icons/emacs.ico ${srcdir}/$(EMACS_MANIFEST) - ${WINDRES} -I ${srcdir} -O coff -o emacs.res ${srcdir}/emacs.rc + ${WINDRES} -I ${srcdir} -O coff -o $@ $< commit 9e8da9d27928ba19bf0c383a080b2fd01ad9f157 Author: Daiki Ueno Date: Tue Nov 18 16:19:14 2014 +0900 epg: Support key editing * epg.el (epg-context): New slot EDIT-CALLBACK. (epg--process-filter): Call EDIT-CALLBACK when editing a key. (epg-reset): Reset EDIT-CALLBACK of the context. (epg-start-edit-key): New function. (epg-edit-key): New function. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index feb9385..e885c92 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2014-11-18 Daiki Ueno + + * epg.el (epg-context): New slot EDIT-CALLBACK. + (epg--process-filter): Call EDIT-CALLBACK when editing a key. + (epg-reset): Reset EDIT-CALLBACK of the context. + (epg-start-edit-key): New function. + (epg-edit-key): New function. + 2014-11-18 Paul Eggert Port new time stamp handling to Emacs 23.2. diff --git a/lisp/epg.el b/lisp/epg.el index 20e6785..520ff8d 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -205,6 +205,7 @@ compress-algorithm (passphrase-callback (list #'epg-passphrase-callback-function)) progress-callback + edit-callback signers sig-notations process @@ -668,15 +669,27 @@ callback data (if any)." (beginning-of-line) (while (looking-at ".*\n") ;the input line finished (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") - (let* ((status (match-string 1)) - (string (match-string 2)) - (symbol (intern-soft (concat "epg--status-" - status)))) + (let ((status (match-string 1)) + (string (match-string 2)) + symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) - (if (and symbol - (fboundp symbol)) - (funcall symbol epg-context string)) + ;; When editing a key, delegate all interaction + ;; to edit-callback. + (if (eq (epg-context-operation epg-context) 'edit-key) + (funcall (car (epg-context-edit-callback + epg-context)) + epg-context + status + string + (cdr (epg-context-edit-callback + epg-context))) + ;; Otherwise call epg--status-STATUS function. + (setq symbol (intern-soft (concat "epg--status-" + status))) + (if (and symbol + (fboundp symbol)) + (funcall symbol epg-context string))) (setq epg-last-status (cons status string))) ;; Record other lines sent to stderr. This assumes ;; that the process-filter receives output only from @@ -736,7 +749,8 @@ callback data (if any)." (if (and (epg-context-process context) (buffer-live-p (process-buffer (epg-context-process context)))) (kill-buffer (process-buffer (epg-context-process context)))) - (setf (epg-context-process context) nil)) + (setf (epg-context-process context) nil) + (setf (epg-context-edit-callback context) nil)) (defun epg-delete-output-file (context) "Delete the output file of CONTEXT." @@ -2084,6 +2098,38 @@ PARAMETERS is a string which tells how to create the key." (epg-errors-to-string errors)))))) (epg-reset context))) +(defun epg-start-edit-key (context key edit-callback handback) + "Initiate an edit operation on KEY. + +EDIT-CALLBACK is called from process filter and takes 3 +arguments: the context, a status, an argument string, and the +handback argument. + +If you use this function, you will need to wait for the completion of +`epg-gpg-program' by using `epg-wait-for-completion' and call +`epg-reset' to clear a temporary output file. +If you are unsure, use synchronous version of this function +`epg-edit-key' instead." + (setf (epg-context-operation context) 'edit-key) + (setf (epg-context-result context) nil) + (setf (epg-context-edit-callback context) (cons edit-callback handback)) + (epg--start context (list "--edit-key" + (epg-sub-key-id + (car (epg-key-sub-key-list key)))))) + +(defun epg-edit-key (context key edit-callback handback) + "Edit KEY in the keyring." + (unwind-protect + (progn + (epg-start-edit-key context key edit-callback handback) + (epg-wait-for-completion context) + (let ((errors (epg-context-result-for context 'error))) + (if errors + (signal 'epg-error + (list "Edit key failed" + (epg-errors-to-string errors)))))) + (epg-reset context))) + (defun epg--decode-percent-escape (string) (let ((index 0)) (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)" commit b3cb91e07c26a3f83f684d9f7248c4492bf8fcc1 Author: Paul Eggert Date: Mon Nov 17 22:44:27 2014 -0800 Port new time stamp handling to Emacs 23.2. This fix is for Gnus. Problem reported by Katsumi Yamaoka. * calendar/time-date.el (time-add, time-subtract, time-less-p): Use eval-and-compile, not eval-when-compile. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2670a66..feb9385 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-11-18 Paul Eggert + + Port new time stamp handling to Emacs 23.2. + This fix is for Gnus. Problem reported by Katsumi Yamaoka. + * calendar/time-date.el (time-add, time-subtract, time-less-p): + Use eval-and-compile, not eval-when-compile. + 2014-11-18 Daiki Ueno * epg.el (epg-context-set-passphrase-callback) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index a9c30f4..e7a8cc7 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -215,7 +215,7 @@ TIME should be either a time value or a date-time string." ;;;###autoload(autoload 'time-subtract "time-date") ;;;###autoload(autoload 'time-less-p "time-date") -(eval-when-compile +(eval-and-compile (when (not (and (fboundp 'time-add) (subrp (symbol-function 'time-add)))) (defun time-add (t1 t2) commit 5c249e2a0470b1bc53d10b5f4cf303922933e280 Author: Daiki Ueno Date: Tue Nov 18 14:52:45 2014 +0900 epg: Fix callback argument type check * epg.el (epg-context-set-passphrase-callback) (epg-context-set-progress-callback): Check if the CALLBACK argument is a function, instead of a cons. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 928c89c..2670a66 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,11 @@ 2014-11-18 Daiki Ueno + * epg.el (epg-context-set-passphrase-callback) + (epg-context-set-progress-callback): Check if the CALLBACK + argument is a function, instead of a cons. + +2014-11-18 Daiki Ueno + * epa-file.el (epa-file-insert-file-contents) (epa-file-write-region): Remove redundant check of epa-pinentry-mode. diff --git a/lisp/epg.el b/lisp/epg.el index e4d8c1e..20e6785 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -252,9 +252,9 @@ installing GnuPG 1.x _along with_ GnuPG 2.x, which does passphrase query by itself and Emacs can intercept them." ;; (declare (obsolete setf "25.1")) (setf (epg-context-passphrase-callback context) - (if (consp passphrase-callback) ;FIXME: functions can also be consp! - passphrase-callback - (list passphrase-callback)))) + (if (functionp passphrase-callback) + (list passphrase-callback) + passphrase-callback))) (defun epg-context-set-progress-callback (context progress-callback) @@ -268,9 +268,9 @@ description, the character to display a progress unit, the current amount done, the total amount to be done, and the callback data (if any)." (setf (epg-context-progress-callback context) - (if (consp progress-callback) ;FIXME: could be a function! - progress-callback - (list progress-callback)))) + (if (functionp progress-callback) + (list progress-callback) + progress-callback))) (defun epg-context-set-signers (context signers) "Set the list of key-id for signing." commit 5224be2f7401bd9999b5442a94d0b2abf7f4da3b Author: Daiki Ueno Date: Tue Nov 18 14:49:30 2014 +0900 epg: Simplify epa-pinentry-mode handling * epa-file.el (epa-file-insert-file-contents) (epa-file-write-region): Remove redundant check of epa-pinentry-mode. * epa.el (epa-sign-file, epa-encrypt-file, epa-decrypt-region) (epa-sign-region, epa-encrypt-region): Remove redundant check of epa-pinentry-mode. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 462d004..928c89c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2014-11-18 Daiki Ueno + * epa-file.el (epa-file-insert-file-contents) + (epa-file-write-region): Remove redundant check of + epa-pinentry-mode. + * epa.el (epa-sign-file, epa-encrypt-file, epa-decrypt-region) + (epa-sign-region, epa-encrypt-region): Remove redundant check of + epa-pinentry-mode. + +2014-11-18 Daiki Ueno + * epa-file.el (epa-file-insert-file-contents): Don't show "*Error*" buffer if input file does not exist. Reported by Herbert J. Skuhra. diff --git a/lisp/epa-file.el b/lisp/epa-file.el index cdaa8ba..2e46cf9 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -144,8 +144,7 @@ encryption is used." context (cons #'epa-progress-callback-function (format "Decrypting %s" file))) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (unwind-protect (progn (if replace @@ -233,8 +232,7 @@ encryption is used." (cons #'epa-progress-callback-function (format "Encrypting %s" file))) (setf (epg-context-armor context) epa-armor) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (condition-case error (setq string (epg-encrypt-string diff --git a/lisp/epa.el b/lisp/epa.el index 2814716..8b95261 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -783,8 +783,7 @@ If no one is selected, default secret key is used. " #'epa-progress-callback-function (format "Signing %s..." (file-name-nondirectory file)))) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (message "Signing %s..." (file-name-nondirectory file)) (condition-case error (epg-sign-file context file signature mode) @@ -815,8 +814,7 @@ If no one is selected, symmetric encryption will be performed. "))) #'epa-progress-callback-function (format "Encrypting %s..." (file-name-nondirectory file)))) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (message "Encrypting %s..." (file-name-nondirectory file)) (condition-case error (epg-encrypt-file context file recipients cipher) @@ -859,8 +857,7 @@ For example: (cons #'epa-progress-callback-function "Decrypting...")) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (message "Decrypting...") (condition-case error (setq plain (epg-decrypt-string context (buffer-substring start end))) @@ -1067,8 +1064,7 @@ If no one is selected, default secret key is used. " (cons #'epa-progress-callback-function "Signing...")) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (message "Signing...") (condition-case error (setq signature (epg-sign-string context @@ -1157,8 +1153,7 @@ If no one is selected, symmetric encryption will be performed. ") (cons #'epa-progress-callback-function "Encrypting...")) - (if epa-pinentry-mode - (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) + (setf (epg-context-pinentry-mode context) epa-pinentry-mode) (message "Encrypting...") (condition-case error (setq cipher (epg-encrypt-string context @@ -1327,8 +1322,7 @@ If no one is selected, default public key is exported. "))) ;; (cons ;; #'epa-progress-callback-function ;; "Signing keys...")) -;; (if epa-pinentry-mode -;; (setf (epg-context-pinentry-mode context) epa-pinentry-mode)) +;; (setf (epg-context-pinentry-mode context) epa-pinentry-mode) ;; (message "Signing keys...") ;; (epg-sign-keys context keys local) ;; (message "Signing keys...done"))) commit b12bb4dc3ecc74c99031538fc8d3565d276a18d7 Author: Daiki Ueno Date: Tue Nov 18 12:46:15 2014 +0900 epg: Don't show "*Error*" buffer when visiting a new file * epa-file.el (epa-file-insert-file-contents): Don't show "*Error*" buffer if input file does not exist. Reported by Herbert J. Skuhra. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 968ea8d..462d004 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-11-18 Daiki Ueno + + * epa-file.el (epa-file-insert-file-contents): Don't show + "*Error*" buffer if input file does not exist. + Reported by Herbert J. Skuhra. + 2014-11-18 Paul Pogonyshev Rüdiger Sonderfeld diff --git a/lisp/epa-file.el b/lisp/epa-file.el index e70bf6d..cdaa8ba 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -153,7 +153,6 @@ encryption is used." (condition-case error (setq string (epg-decrypt-file context local-file nil)) (error - (epa-display-error context) (if (setq entry (assoc file epa-file-passphrase-alist)) (setcdr entry nil)) ;; If the decryption program can't be found, @@ -164,15 +163,16 @@ encryption is used." (equal (cadr error) "Searching for program")) (error "Decryption program `%s' not found" (nth 3 error))) - ;; Hack to prevent find-file from opening empty buffer - ;; when decryption failed (bug#6568). See the place - ;; where `find-file-not-found-functions' are called in - ;; `find-file-noselect-1'. (when (file-exists-p local-file) + ;; Hack to prevent find-file from opening empty buffer + ;; when decryption failed (bug#6568). See the place + ;; where `find-file-not-found-functions' are called in + ;; `find-file-noselect-1'. (setq-local epa-file-error error) (add-hook 'find-file-not-found-functions 'epa-file--find-file-not-found-function - nil t)) + nil t) + (epa-display-error context)) (signal 'file-error (cons "Opening input file" (cdr error))))) (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! commit 0b37f903b62b29726644dbad330d2a0bf91d85d6 Author: Paul Pogonyshev Date: Tue Nov 18 03:34:01 2014 +0100 progmodes/cc-langs.el: Support some of the new keywords in C++11. (c-operators): Add "alignof". (c-primitive-type-kwds): Add "char16_t", "char32_t". (c-type-modifier-kwds): Add "constexpr", "noexcept". (c-modifier-kwds): Add "thread_local". (c-constant-kwds): Add "nullptr". Original patch by Paul Pogonyshev and updated by Rüdiger Sonderfeld . diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0075c5a..968ea8d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2014-11-18 Paul Pogonyshev + Rüdiger Sonderfeld + + * progmodes/cc-langs.el: Support some of the new keywords in + C++11. + (c-operators): Add "alignof". + (c-primitive-type-kwds): Add "char16_t", "char32_t". + (c-type-modifier-kwds): Add "constexpr", "noexcept". + (c-modifier-kwds): Add "thread_local". + (c-constant-kwds): Add "nullptr". + 2014-11-17 Michal Nazarewicz * textmodes/tildify.el (tildify-pattern, tildify-space-string): diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 2a5db6d..68b2d62 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -970,7 +970,8 @@ since CC Mode treats every identifier as an expression." ,@(when (c-major-mode-is 'c++-mode) ;; The following need special treatment. `((prefix "dynamic_cast" "static_cast" - "reinterpret_cast" "const_cast" "typeid"))) + "reinterpret_cast" "const_cast" "typeid" + "alignof"))) (left-assoc "." ,@(unless (c-major-mode-is 'java-mode) '("->"))) @@ -1648,7 +1649,7 @@ the appropriate place for that." '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99. (c-lang-const c-primitive-type-kwds)) c++ (append - '("bool" "wchar_t") + '("bool" "wchar_t" "char16_t" "char32_t") (c-lang-const c-primitive-type-kwds)) ;; Objective-C extends C, but probably not the new stuff in C99. objc (append @@ -1730,7 +1731,7 @@ but they don't build a type of themselves. Unlike the keywords on not the type face." t nil c '("const" "restrict" "volatile") - c++ '("const" "volatile" "throw") + c++ '("const" "constexpr" "noexcept" "volatile" "throw") objc '("const" "volatile")) (c-lang-defconst c-opt-type-modifier-key @@ -1932,7 +1933,8 @@ If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', will be handled." t nil (c c++) '("auto" "extern" "inline" "register" "static") - c++ (append '("explicit" "friend" "mutable" "template" "using" "virtual") + c++ (append '("explicit" "friend" "mutable" "template" "thread_local" + "using" "virtual") (c-lang-const c-modifier-kwds)) objc '("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static") ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead. @@ -2384,8 +2386,11 @@ This construct is \" :\"." (c-lang-defconst c-constant-kwds "Keywords for constants." t nil - (c c++) '("NULL" ;; Not a keyword, but practically works as one. + c '("NULL" ;; Not a keyword, but practically works as one. "false" "true") ; Defined in C99. + c++ (append + '("nullptr") + (c-lang-const c-constant-kwds)) objc '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER") idl '("TRUE" "FALSE") java '("true" "false" "null") ; technically "literals", not keywords commit 1901029f6b6aadd210001b2154282bec0b9d3b07 Author: Michal Nazarewicz Date: Mon Nov 17 14:41:37 2014 +0100 tildify.el: introduce a `tildify-foreach-region-function' variable * textmodes/tildify.el (tildify-foreach-region-function): New variable specifying a function determining portions of buffer that should be tildified. It allows major modes to create a filtering function more elaborate than a set of regular expressions. Initialised to `tildify--deprecated-ignore-evironments' by default to handle now deprecated `tildify-ignored-environments-alist' variable. (tildify--foreach-region): A new function that takes `tildify-foreach-region-function' into account and calls callback for regions of the buffer that should be tildified. (tildify-foreach-ignore-environments): A new function which can be partially applied and used as `tildify-foreach-region-function'. (tildify-ignored-environments-alist, tildify--pick-alist-entry): Mark as obsolete. (tildify--find-env): Rename from `tildify-find-env' and mark as obsolete. (tildify--deprecated-ignore-evironments): New function, immediately marked as obsolete, used to handle deprecated `tildify-ignored-environments-alist'. * textmodes/tex-mode.el (tex-common-initialization): Set `tildify-foreach-region-function' variable in all variants of TeX mode since `tildify-ignored-environments-alist' variable is now empty by default. * nxml/nxml-mode.el (nxml-mode): Ditto in `nxml-mode'. * textmodes/sgml-mode.el (sgml-mode): Ditto in `sgml-mode'. diff --git a/etc/NEWS b/etc/NEWS index 61d1cd7..86e21c4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -301,8 +301,11 @@ use PDF instead of DVI. By default, 32 spaces and four TABs are considered to be too much but `whitespace-big-indent-regexp' can be configured to change that. -** tildify: `tildify-space-string' and `tildify-pattern' variables added making -`tildify-string-alist' and `tildify-pattern-alist' obsolete. +** tildify: `tildify-space-string', `tildify-pattern', and +`tildify-foreach-region-function' variables added making +`tildify-string-alist', `tildify-pattern-alist', and +`tildify-ignored-environments-alist' variables (as well as a few +helper functions) obsolete. ** Obsolete packages diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f5bd527..0075c5a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -7,11 +7,29 @@ `tildify-string-alist' and `tildify-pattern-alist' respectively that have been used so far. They also works better with derived modes. - (tildify-pattern, tildify-string-alist): Mark as obsolete. + (tildify-foreach-region-function): New variable specifying + a function determining portions of buffer that should be + tildified. It allows major modes to create a filtering function + more elaborate than a set of regular expressions. Initialised to + `tildify--deprecated-ignore-evironments' by default to handle now + deprecated `tildify-ignored-environments-alist' variable. + (tildify--foreach-region): A new function that takes + `tildify-foreach-region-function' into account and calls callback + for regions of the buffer that should be tildified. + (tildify-foreach-ignore-environments): A new function which can be + partially applied and used as `tildify-foreach-region-function'. + (tildify-ignored-environments-alist, tildify-pattern) + (tildify-string-alist, tildify--pick-alist-entry): Mark as obsolete. + (tildify--find-env): Rename from `tildify-find-env' and mark as + obsolete. + (tildify--deprecated-ignore-evironments): New function, + immediately marked as obsolete, used to handle deprecated + `tildify-ignored-environments-alist'. * textmodes/tex-mode.el (tex-common-initialization): Set - `tildify-space-string' variable in all variants of TeX mode since - `tildify-string-alist' is now empty by default. + `tildify-space-string' and `tildify-foreach-region-function' + variables in all variants of TeX mode since `tildify-string-alist' + and `tildify-ignored-environments-alist' are now empty by default. * nxml/nxml-mode.el (nxml-mode): Ditto in `nxml-mode'. If encoding supports it use no-break space instead of character @@ -20,7 +38,7 @@ * textmodes/sgml-mode.el (sgml-mode): ditto in `sgml-mode'. If encoding does not support no-break space, use numeric reference; - this changes previous default which used named entity (? ?) + this changes previous default which used named entity (“ ”) in HTML mode. 2014-11-17 Ulf Jasper diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 47f8066..b198f4a 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -450,6 +450,7 @@ reference.") (rng-validate-while-idle (current-buffer))))) (defvar tildify-space-string) +(defvar tildify-foreach-region-function) ;;;###autoload (define-derived-mode nxml-mode text-mode "nXML" @@ -515,6 +516,11 @@ Many aspects this mode can be customized using (encode-coding-string " " buffer-file-coding-system) buffer-file-coding-system) " ") " " " ")) + ;; FIXME: Use the fact that we're parsing the document already + ;; rather than using regex-based filtering. + (setq-local tildify-foreach-region-function + (apply-partially 'tildify-foreach-ignore-environments + '(("") ("<" . ">")))) (set (make-local-variable 'mode-line-process) '((nxml-degraded "/degraded"))) ;; We'll determine the fill prefix ourselves (make-local-variable 'adaptive-fill-mode) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 9d1cb03..73b5292 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -457,6 +457,7 @@ This function is designed for use in `fill-nobreak-predicate'. (eq (char-before) ?<)))) (defvar tildify-space-string) +(defvar tildify-foreach-region-function) ;;;###autoload (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML") @@ -486,6 +487,20 @@ Do \\[describe-key] on the following bindings to discover what they do. (encode-coding-string " " buffer-file-coding-system) buffer-file-coding-system) " ") " " " ")) + ;; FIXME: Use the fact that we're parsing the document already + ;; rather than using regex-based filtering. + (setq-local tildify-foreach-region-function + (apply-partially + 'tildify-foreach-ignore-environments + `((,(eval-when-compile + (concat + "<\\(" + (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var" + "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR")) + "\\)\\>[^>]*>")) + . ("")) + ("") + ("<" . ">")))) ;;(make-local-variable 'facemenu-remove-face-function) ;; A start or end tag by itself on a line separates a paragraph. ;; This is desirable because SGML discards a newline that appears diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 0cfc0cf..1993ff1 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1204,12 +1204,31 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}")) (defvar tildify-space-string) +(defvar tildify-foreach-region-function) (defun tex-common-initialization () ;; Regexp isearch should accept newline and formfeed as whitespace. (setq-local search-whitespace-regexp "[ \t\r\n\f]+") ;; Use tilde as hard-space character in tildify package. (setq-local tildify-space-string "~") + ;; FIXME: Use the fact that we're parsing the document already + ;; rather than using regex-based filtering. + (setq-local tildify-foreach-region-function + (apply-partially + 'tildify-foreach-ignore-environments + `(("\\\\\\\\" . "") ; do not remove this + (,(eval-when-compile + (concat "\\\\begin{\\(" + (regexp-opt '("verbatim" "math" "displaymath" + "equation" "eqnarray" "eqnarray*")) + "\\)}")) + . ("\\\\end{" 1 "}")) + ("\\\\verb\\*?\\(.\\)" . (1)) + ("\\$\\$?" . (0)) + ("\\\\(" . "\\\\)") + ("\\\\[[]" . "\\\\[]]") + ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "") + ("%" . "$")))) ;; A line containing just $$ is treated as a paragraph separator. (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") ;; A line starting with $$ starts a paragraph, diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 6006968..d935ff7 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -1,10 +1,10 @@ -;;; tildify.el --- adding hard spaces into texts +;;; tildify.el --- adding hard spaces into texts -*- lexical-binding: t -*- ;; Copyright (C) 1997-2014 Free Software Foundation, Inc. ;; Author: Milan Zamazal ;; Michal Nazarewicz -;; Version: 4.5.6 +;; Version: 4.5.7 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -143,36 +143,31 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (make-obsolete-variable 'tildify-string-alist 'tildify-space-string "25.1") -(defcustom tildify-ignored-environments-alist - `((latex-mode - ("\\\\\\\\" . "") ; do not remove this - (,(eval-when-compile (concat - "\\\\begin{\\(" - (regexp-opt '("verbatim" "math" "displaymath" - "equation" "eqnarray" "eqnarray*")) - "\\)}")) - . ("\\\\end{" 1 "}")) - ("\\\\verb\\*?\\(.\\)" . (1)) - ("\\$\\$?" . (0)) - ("\\\\(" . "\\\\)") - ("\\\\[[]" . "\\\\[]]") - ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "") - ("%" . "$")) - (plain-tex-mode . latex-mode) - (html-mode - (,(eval-when-compile (concat - "<\\(" - (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var" - "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR")) - "\\)\\>[^>]*>")) - . ("")) - ("") - ("<" . ">")) - (sgml-mode . html-mode) - (xml-mode - ("") - ("<" . ">")) - (nxml-mode . xml-mode)) +(defcustom tildify-foreach-region-function + 'tildify--deprecated-ignore-evironments + "A function calling a callback on portions of the buffer to tildify. + +The function is called from `tildify-buffer' function with three arguments: FUNC +BEG END. FUNC is a callback accepting two arguments -- REG-BEG REG-END -- +specifying a portion of buffer to operate on. + +The BEG and END arguments may be used to limit portion of the buffer being +scanned, but the `tildify-foreach-region-function' is not required to make use +of them. IT must, however, terminate as soon as FUNC returns nil. + +For example, if `tildify-buffer' function should operate on the whole buffer, +a simple pass through function could be used: + (setq-local tildify-foreach-region-function + (lambda (cb beg end) (funcall cb beg end))) +or better still: + (setq-local tildify-foreach-region-function 'funcall) +See `tildify-foreach-ignore-environments' function for other ways to use the +variable." + :version "25.1" + :group 'tildify + :type 'function) + +(defcustom tildify-ignored-environments-alist () "Alist specifying ignored structured text environments. Parts of text defined in this alist are skipped without performing hard space insertion on them. These setting allow skipping text parts like verbatim or @@ -186,13 +181,8 @@ MAJOR-MODE defines major mode, for which the item applies. It can be either: - t for default item, this applies to all major modes not defined in another alist item -BEG-REGEX is a regexp matching beginning of a text part to be skipped. -END-REGEX defines end of the corresponding text part and can be either: -- a regexp matching the end of the skipped text part -- a list of regexps and numbers, which will compose the ending regexp by - concatenating themselves, while replacing the numbers with corresponding - subexpressions of BEG-REGEX (this is used to solve cases like - \\\\verb in TeX)." +See `tildify-foreach-ignore-environments' function for description of BEG-REGEX +and END-REGEX." :group 'tildify :type '(repeat (cons :tag "Entry for major mode" @@ -210,6 +200,8 @@ END-REGEX defines end of the corresponding text part and can be either: (choice (regexp :tag "Regexp") (integer :tag "Group ")))))) (symbol :tag "Like other"))))) +(make-obsolete-variable 'tildify-ignored-environments-alist + 'tildify-foreach-region-function "25.1") ;;; *** Interactive functions *** @@ -225,14 +217,15 @@ If DONT-ASK is set, or called interactively with prefix argument, user won't be prompted for confirmation of each substitution." (interactive "*rP") (let (case-fold-search (count 0) (ask (not dont-ask))) - (tildify-foreach-region-outside-env beg end + (tildify--foreach-region (lambda (beg end) (let ((aux (tildify-tildify beg end ask))) (setq count (+ count (car aux))) (if (not (eq (cdr aux) 'force)) (cdr aux) (setq ask nil) - t)))) + t))) + beg end) (message "%d spaces replaced." count))) ;;;###autoload @@ -258,40 +251,76 @@ won't be prompted for confirmation of each substitution." (symbolp alist)) (tildify--pick-alist-entry mode-alist alist) alist))) +(make-obsolete 'tildify--pick-alist-entry + "it should not be used in new code." "25.1") + +(defun tildify--deprecated-ignore-evironments (callback beg end) + "Call CALLBACK on regions between BEG and END. -(defun tildify-foreach-region-outside-env (beg end callback) - "Scan region from BEG to END calling CALLBACK on portions out of environments. -Call CALLBACK on each region outside of environment to ignore. -CALLBACK will only be called for regions which have intersection -with [BEG END]. It must be a function that takes two point -arguments specifying the region to operate on. Stop scanning the -region as soon as CALLBACK returns nil. Environments to ignore -are determined from `tildify-ignored-environments-alist'." - (declare (indent 2)) +Call CALLBACK on each region outside of environment to ignore. Stop scanning +the region as soon as CALLBACK returns nil. Environments to ignore are +defined by deprecated `tildify-ignored-environments-alist'. CALLBACK may be +called on portions of the buffer outside of [BEG END)." (let ((pairs (tildify--pick-alist-entry tildify-ignored-environments-alist))) - (if (not pairs) - (funcall callback beg end) - (let ((func (lambda (b e) - (let ((b (max b beg)) (e (min e end))) - (if (< b e) (funcall callback b e) t)))) - (beg-re (concat "\\(?:" - (mapconcat 'car pairs "\\)\\|\\(?:") - "\\)")) - p end-re) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (and (< (setq p (point)) end) - (if (not (setq end-re - (tildify-find-env beg-re pairs))) - (progn (funcall func p end) nil) - (funcall func p (match-beginning 0)) - (when (< (point) end) - (setq p (point)) - (re-search-forward end-re nil t))))))))))) - -(defun tildify-find-env (regexp pairs) + (if pairs + (tildify-foreach-ignore-environments pairs callback beg end) + (funcall callback beg end)))) +(make-obsolete 'tildify--deprecated-ignore-evironments + "it should not be used in new code." "25.1") + +(defun tildify-foreach-ignore-environments (pairs callback _beg end) + "Outside of environments defined by PAIRS call CALLBACK. + +PAIRS is a list of (BEG-REGEX . END-REGEX) cons. BEG-REGEX is a regexp matching +beginning of a text part to be skipped. END-REGEX defines end of the +corresponding text part and can be either: +- a regexp matching the end of the skipped text part +- a list of regexps and numbers, which will compose the ending regexp by + concatenating themselves, while replacing the numbers with corresponding + subexpressions of BEG-REGEX (this is used to solve cases like + \\\\verb in TeX). + +CALLBACK is a function accepting two arguments -- REG-BEG and REG-END -- that +will be called for portions of the buffer outside of the environments defined by +PAIRS regexes. + +The function will return as soon as CALLBACK returns nil or point goes past END. +CALLBACK may be called on portions of the buffer outside of [BEG END); in fact +BEG argument is ignored. + +This function is meant to be used to set `tildify-foreach-region-function' +variable. For example, for an XML file one might use: + (setq-local tildify-foreach-region-function + (apply-partially 'tildify-foreach-ignore-environments + '((\"\") (\"<\" . \">\"))))" + (let ((beg-re (concat "\\(?:" (mapconcat 'car pairs "\\)\\|\\(?:") "\\)")) + p end-re) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (while (and (< (setq p (point)) end) + (if (setq end-re (tildify--find-env beg-re pairs)) + (and (funcall callback p (match-beginning 0)) + (< (point) end) + (re-search-forward end-re nil t)) + (funcall callback p end) + nil))))))) + +(defun tildify--foreach-region (callback beg end) + "Call CALLBACK on portions of the buffer between BEG and END. + +Which portions to call CALLBACK on is determined by +`tildify-foreach-region-function' variable. This function merely makes sure +CALLBACK is not called with portions of the buffer outside of [BEG END)." + (let ((func (lambda (reg-beg reg-end) + (setq reg-beg (max reg-beg beg) reg-end (min reg-end end)) + (and (or (>= reg-beg reg-end) + (funcall callback reg-beg reg-end)) + (< reg-end end))))) + (funcall tildify-foreach-region-function func beg end))) + +(defun tildify--find-env (regexp pairs) "Find environment using REGEXP. Return regexp for the end of the environment found in PAIRS or nil if no environment was found." diff --git a/test/ChangeLog b/test/ChangeLog index 1c739d4..475b6a3 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -2,6 +2,14 @@ * automated/tildify-tests.el (tildify-test-html, tildify-test-xml): HTML and XML now use no-break space as hard space. Update tests. + (tildify-test-foreach-ignore-environments) + (tildify-test-foreach-ignore-environments-early-return, + (tildify-test-foreach-region) + (tildify-test-foreach-region-early-return) + (tildify-test-foreach-region-limit-region): New tests of + `tildify-foreach-ignore-environments' and + `tildify--foreach-region' functions. + (with-test-foreach): New helper macro for the above tests. 2014-11-17 Glenn Morris diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index e532cf0..55d2d57 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -1,4 +1,4 @@ -;;; tildify-test.el --- ERT tests for tildify.el +;;; tildify-test.el --- ERT tests for tildify.el -*- lexical-binding: t -*- ;; Copyright (C) 2014 Free Software Foundation, Inc. @@ -117,8 +117,8 @@ latter is missing, SENTENCE will be used in all placeholder positions." (insert "foo whatever end-foo") (goto-char (point-min)) (should (string-equal "end-foo" - (tildify-find-env "foo\\|bar" - '(("foo\\|bar" . ("end-" 0)))))))) + (tildify--find-env "foo\\|bar" + '(("foo\\|bar" . ("end-" 0)))))))) (ert-deftest tildify-test-find-env-group-index-bug () @@ -129,7 +129,60 @@ latter is missing, SENTENCE will be used in all placeholder positions." (beg-re "start-\\(foo\\|bar\\)\\|open-\\(foo\\|bar\\)")) (insert "open-foo whatever close-foo") (goto-char (point-min)) - (should (string-equal "close-foo" (tildify-find-env beg-re pairs)))))) + (should (string-equal "close-foo" (tildify--find-env beg-re pairs)))))) + + +(defmacro with-test-foreach (expected &rest body) + "Helper macro for testing foreach functions. +BODY has access to pairs variable and called lambda." + (declare (indent 1)) + (let ((got (make-symbol "got"))) + `(with-temp-buffer + (insert "1 /- 2 -/ 3 V~ 4 ~ 5 /- 6 -/ 7") + (let* ((pairs '(("/-" . "-/") ("V\\(.\\)" . (1)))) + (,got "") + (called (lambda (s e) + (setq ,got (concat ,got (buffer-substring s e)))))) + (setq-local tildify-foreach-region-function + (apply-partially 'tildify-foreach-ignore-environments + pairs)) + ,@body + (should (string-equal ,expected ,got)))))) + +(ert-deftest tildify-test-foreach-ignore-environments () + "Basic test of `tildify-foreach-ignore-environments'" + (with-test-foreach "1 3 5 7" + (tildify-foreach-ignore-environments pairs called (point-min) (point-max)))) + + +(ert-deftest tildify-test-foreach-ignore-environments-early-return () + "Test whether `tildify-foreach-ignore-environments' returns early +The function must terminate as soon as callback returns nil." + (with-test-foreach "1 " + (tildify-foreach-ignore-environments + pairs (lambda (start end) (funcall called start end) nil) + (point-min) (point-max)))) + +(ert-deftest tildify-test-foreach-region () + "Basic test of `tildify--foreach-region'" + (with-test-foreach "1 3 5 7" + (tildify--foreach-region called (point-min) (point-max)))) + +(ert-deftest tildify-test-foreach-region-early-return () + "Test whether `tildify--foreach-ignore' returns early +The function must terminate as soon as callback returns nil." + (with-test-foreach "1 " + (tildify--foreach-region (lambda (start end) (funcall called start end) nil) + (point-min) (point-max)))) + +(ert-deftest tildify-test-foreach-region-limit-region () + "Test whether `tildify--foreach-ignore' limits callback to given region" + (with-test-foreach "3 " + (tildify--foreach-region called + (+ (point-min) 10) (+ (point-min) 16))) ; start at "3" end past "4" + (with-test-foreach "3 5" + (tildify--foreach-region called + (+ (point-min) 10) (+ (point-min) 20)))) ; start at "3" end past "5" (provide 'tildify-tests) commit d5ec102b7aa0aa07bdd44ecd0b471275511fed7e Author: Michal Nazarewicz Date: Sun Nov 16 18:08:36 2014 +0100 tildify.el: introduce a `tildify-pattern' variable * textmodes/tildify.el (tildify-pattern): New variable for defining tildifying pattern. Being a buffer-local variable it is much easier to handle than `tildify-pattern-alist' that has been used so far. It also works better with derived modes. (tildify-pattern-alist): Mark as obsolete. diff --git a/etc/NEWS b/etc/NEWS index d03ce7c..61d1cd7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -301,8 +301,8 @@ use PDF instead of DVI. By default, 32 spaces and four TABs are considered to be too much but `whitespace-big-indent-regexp' can be configured to change that. -** tildify: `tildify-space-string' variable has been added making -`tildify-string-alist' obsolete. +** tildify: `tildify-space-string' and `tildify-pattern' variables added making +`tildify-string-alist' and `tildify-pattern-alist' obsolete. ** Obsolete packages diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 33d341f..f5bd527 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,11 +1,13 @@ 2014-11-17 Michal Nazarewicz - * textmodes/tildify.el (tildify-space-string): New variable for - specifying representation of a hard space -- a no-break space by - default. Being a buffer-local variable it is much easier to - handle than `tildify-string-alist' that has been used so far. It - also works better with derived modes. - (tildify-string-alist): Mark as obsolete. + * textmodes/tildify.el (tildify-pattern, tildify-space-string): + New variables for specifying tildify pattern and representation of + a hard space -- a no-break space by default -- respectively. + Being buffer-local they are much easier to handle than + `tildify-string-alist' and `tildify-pattern-alist' respectively + that have been used so far. They also works better with derived + modes. + (tildify-pattern, tildify-string-alist): Mark as obsolete. * textmodes/tex-mode.el (tex-common-initialization): Set `tildify-space-string' variable in all variants of TeX mode since diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 865dcec..6006968 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -4,7 +4,7 @@ ;; Author: Milan Zamazal ;; Michal Nazarewicz -;; Version: 4.5.5 +;; Version: 4.5.6 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -56,8 +56,21 @@ :version "21.1" :group 'wp) -(defcustom tildify-pattern-alist - '((t "\\([,:;(][ \t]*[a]\\|\\<[AIKOSUVZikosuvz]\\)\\([ \t]+\\|[ \t]*\n[ \t]*\\)\\(\\w\\|[([{\\]\\|<[a-zA-Z]\\)" 2)) +(defcustom tildify-pattern + "\\(?:[,:;(][ \t]*[a]\\|\\<[AIKOSUVZikosuvz]\\)\\([ \t]+\\|[ \t]*\n[ \t]*\\)\\(?:\\w\\|[([{\\]\\|<[a-zA-Z]\\)" + "A pattern specifying where to insert hard spaces. + +`tildify-buffer' function will replace first capturing group of the regexp with +a hard space (as defined by `tildify-space-string' variable). (Hint: \\(…\\) +non-capturing groups can be used for grouping prior to the part of the regexp +matching the white space). The pattern is matched case-sensitive regardless of +the value of `case-fold-search' setting." + :version "25.1" + :group 'tildify + :type 'string + :safe t) + +(defcustom tildify-pattern-alist () "Alist specifying where to insert hard spaces. Each alist item is of the form (MAJOR-MODE REGEXP NUMBER) or @@ -85,6 +98,7 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." regexp (integer :tag "Group ")) (symbol :tag "Like other"))))) +(make-obsolete-variable 'tildify-pattern-alist 'tildify-pattern "25.1") (defcustom tildify-space-string "\u00A0" "Representation of a hard (a.k.a. no-break) space in current major mode. @@ -115,8 +129,7 @@ MAJOR-MODE defines major mode, for which the item applies. It can be either: alist item STRING defines the hard space, which is inserted at places defined by -`tildify-pattern-alist'. For example it can be \"~\" for TeX or \" \" -for SGML. +`tildify-pattern'. For example it can be \"~\" for TeX or \" \" for SGML. The form (MAJOR-MODE . SYMBOL) defines alias item for MAJOR-MODE. For this mode, the item for the mode SYMBOL is looked up in the alist instead." @@ -204,7 +217,7 @@ END-REGEX defines end of the corresponding text part and can be either: ;;;###autoload (defun tildify-region (beg end &optional dont-ask) "Add hard spaces in the region between BEG and END. -See variables `tildify-pattern-alist', `tildify-space-string', and +See variables `tildify-pattern', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -225,7 +238,7 @@ won't be prompted for confirmation of each substitution." ;;;###autoload (defun tildify-buffer (&optional dont-ask) "Add hard spaces in the current buffer. -See variables `tildify-pattern-alist', `tildify-space-string', and +See variables `tildify-pattern', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -311,18 +324,21 @@ replacements done and response is one of symbols: t (all right), nil (quit), force (replace without further questions)." (save-excursion (goto-char beg) - (let* ((alist (tildify--pick-alist-entry tildify-pattern-alist)) - (regexp (car alist)) - (match-number (cadr alist)) - (tilde (or (tildify--pick-alist-entry tildify-string-alist) - tildify-space-string)) - (end-marker (copy-marker end)) - answer - bad-answer - replace - quit - (message-log-max nil) - (count 0)) + (let ((regexp tildify-pattern) + (match-number 1) + (tilde (or (tildify--pick-alist-entry tildify-string-alist) + tildify-space-string)) + (end-marker (copy-marker end)) + answer + bad-answer + replace + quit + (message-log-max nil) + (count 0)) + ;; For the time being, tildify-pattern-alist overwrites tildify-pattern + (let ((alist (tildify--pick-alist-entry tildify-pattern-alist))) + (when alist + (setq regexp (car alist) match-number (cadr alist)))) (while (and (not quit) (re-search-forward regexp (marker-position end-marker) t)) (when (or (not ask) commit b8104090075eb28dd6680cc9f8b0a49674ca369a Author: Michal Nazarewicz Date: Sun Nov 16 17:38:15 2014 +0100 tildify.el: introduce a `tildify-space-string' variable * textmodes/tildify.el (tildify-space-string): New variable for specifying representation of a hard space -- a no-break space by default. Being a buffer-local variable it is much easier to handle than `tildify-string-alist' that has been used so far. It also works better with derived modes. (tildify-string-alist): Mark as obsolete. * textmodes/tex-mode.el (tex-common-initialization): Set `tildify-space-string' variable in all variants of TeX mode since `tildify-string-alist' is now empty by default. * nxml/nxml-mode.el (nxml-mode): Ditto in `nxml-mode'. If encoding supports it use no-break space instead of character entity; this changes previous default which used a numeric reference. * textmodes/sgml-mode.el (sgml-mode): ditto in `sgml-mode'. If encoding does not support no-break space, use numeric reference; this changes previous default which used named entity (“ ”) in HTML mode. diff --git a/etc/NEWS b/etc/NEWS index ecbbf74..d03ce7c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -301,6 +301,9 @@ use PDF instead of DVI. By default, 32 spaces and four TABs are considered to be too much but `whitespace-big-indent-regexp' can be configured to change that. +** tildify: `tildify-space-string' variable has been added making +`tildify-string-alist' obsolete. + ** Obsolete packages --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 696b384..33d341f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,26 @@ +2014-11-17 Michal Nazarewicz + + * textmodes/tildify.el (tildify-space-string): New variable for + specifying representation of a hard space -- a no-break space by + default. Being a buffer-local variable it is much easier to + handle than `tildify-string-alist' that has been used so far. It + also works better with derived modes. + (tildify-string-alist): Mark as obsolete. + + * textmodes/tex-mode.el (tex-common-initialization): Set + `tildify-space-string' variable in all variants of TeX mode since + `tildify-string-alist' is now empty by default. + + * nxml/nxml-mode.el (nxml-mode): Ditto in `nxml-mode'. If + encoding supports it use no-break space instead of character + entity; this changes previous default which used a numeric + reference. + + * textmodes/sgml-mode.el (sgml-mode): ditto in `sgml-mode'. If + encoding does not support no-break space, use numeric reference; + this changes previous default which used named entity (? ?) + in HTML mode. + 2014-11-17 Ulf Jasper Fix bug#5433. diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 4859bbc..47f8066 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -449,6 +449,8 @@ reference.") (when rng-validate-mode (rng-validate-while-idle (current-buffer))))) +(defvar tildify-space-string) + ;;;###autoload (define-derived-mode nxml-mode text-mode "nXML" ;; We use C-c C-i instead of \\[nxml-balanced-close-start-tag-inline] @@ -505,6 +507,14 @@ be treated as a single markup item, set the variable Many aspects this mode can be customized using \\[customize-group] nxml RET." ;; (kill-all-local-variables) + ;; If encoding does not allow non-break space character, use reference. + ;; FIXME: This duplicates code from sgml-mode, perhaps derive from it? + ;; FIXME: Perhaps use   if possible (e.g. XHTML)? + (setq-local tildify-space-string + (if (equal (decode-coding-string + (encode-coding-string " " buffer-file-coding-system) + buffer-file-coding-system) " ") + " " " ")) (set (make-local-variable 'mode-line-process) '((nxml-degraded "/degraded"))) ;; We'll determine the fill prefix ourselves (make-local-variable 'adaptive-fill-mode) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 39ac062..9d1cb03 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -456,6 +456,8 @@ This function is designed for use in `fill-nobreak-predicate'. (skip-chars-backward "/?!") (eq (char-before) ?<)))) +(defvar tildify-space-string) + ;;;###autoload (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML") "Major mode for editing SGML documents. @@ -477,6 +479,13 @@ Do \\[describe-key] on the following bindings to discover what they do. \\{sgml-mode-map}" (make-local-variable 'sgml-saved-validate-command) (make-local-variable 'facemenu-end-add-face) + ;; If encoding does not allow non-break space character, use reference. + ;; FIXME: Perhaps use   if possible (e.g. when we know its HTML)? + (setq-local tildify-space-string + (if (equal (decode-coding-string + (encode-coding-string " " buffer-file-coding-system) + buffer-file-coding-system) " ") + " " " ")) ;;(make-local-variable 'facemenu-remove-face-function) ;; A start or end tag by itself on a line separates a paragraph. ;; This is desirable because SGML discards a newline that appears diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index bc10eab..0cfc0cf 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1203,9 +1203,13 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook (setq tex-command slitex-run-command) (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}")) +(defvar tildify-space-string) + (defun tex-common-initialization () ;; Regexp isearch should accept newline and formfeed as whitespace. (setq-local search-whitespace-regexp "[ \t\r\n\f]+") + ;; Use tilde as hard-space character in tildify package. + (setq-local tildify-space-string "~") ;; A line containing just $$ is treated as a paragraph separator. (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") ;; A line starting with $$ starts a paragraph, diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 91f5a38..865dcec 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -4,7 +4,7 @@ ;; Author: Milan Zamazal ;; Michal Nazarewicz -;; Version: 4.5.4 +;; Version: 4.5.5 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -86,15 +86,24 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (integer :tag "Group ")) (symbol :tag "Like other"))))) -(defcustom tildify-string-alist - '((latex-mode . "~") - (tex-mode . latex-mode) - (plain-tex-mode . latex-mode) - (sgml-mode . " ") - (html-mode . sgml-mode) - (xml-mode . " ") ; XML does not define   use numeric reference - (nxml-mode . xml-mode) - (t . " ")) +(defcustom tildify-space-string "\u00A0" + "Representation of a hard (a.k.a. no-break) space in current major mode. + +Used by `tildify-buffer' in places where space is required but line +cannot be broken. For example \"~\" for TeX or \" \" for SGML, +HTML and XML modes. A no-break space Unicode character (\"\\u00A0\") +might be used for other modes if compatible encoding is used. + +If nil, current major mode has no way to represent a hard space." + :version "25.1" + :group 'tildify + :type '(choice (const :tag "Space character (no hard-space representation)" + " ") + (const :tag "No-break space (U+00A0)" "\u00A0") + (string :tag "Custom string")) + :safe t) + +(defcustom tildify-string-alist () "Alist specifying what is a hard space in the current major mode. Each alist item is of the form (MAJOR-MODE . STRING) or @@ -118,6 +127,8 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (choice (const :tag "No-break space (U+00A0)" "\u00A0") (string :tag "String ") (symbol :tag "Like other"))))) +(make-obsolete-variable 'tildify-string-alist + 'tildify-space-string "25.1") (defcustom tildify-ignored-environments-alist `((latex-mode @@ -193,7 +204,7 @@ END-REGEX defines end of the corresponding text part and can be either: ;;;###autoload (defun tildify-region (beg end &optional dont-ask) "Add hard spaces in the region between BEG and END. -See variables `tildify-pattern-alist', `tildify-string-alist', and +See variables `tildify-pattern-alist', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -214,7 +225,7 @@ won't be prompted for confirmation of each substitution." ;;;###autoload (defun tildify-buffer (&optional dont-ask) "Add hard spaces in the current buffer. -See variables `tildify-pattern-alist', `tildify-string-alist', and +See variables `tildify-pattern-alist', `tildify-space-string', and `tildify-ignored-environments-alist' for information about configuration parameters. This function performs no refilling of the changed text. @@ -303,7 +314,8 @@ replacements done and response is one of symbols: t (all right), nil (let* ((alist (tildify--pick-alist-entry tildify-pattern-alist)) (regexp (car alist)) (match-number (cadr alist)) - (tilde (tildify--pick-alist-entry tildify-string-alist)) + (tilde (or (tildify--pick-alist-entry tildify-string-alist) + tildify-space-string)) (end-marker (copy-marker end)) answer bad-answer diff --git a/test/ChangeLog b/test/ChangeLog index 2dfd515..1c739d4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2014-11-17 Michal Nazarewicz + + * automated/tildify-tests.el (tildify-test-html, tildify-test-xml): + HTML and XML now use no-break space as hard space. Update tests. + 2014-11-17 Glenn Morris * automated/occur-tests.el (occur-test-case, occur-test-create): diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index 53c2e62..e532cf0 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -73,7 +73,7 @@ after `tildify-buffer' is run." (ert-deftest tildify-test-html () "Tests tildification in an HTML document" (let* ((sentence (tildify-test--example-sentence " ")) - (with-nbsp (tildify-test--example-sentence " "))) + (with-nbsp (tildify-test--example-sentence " "))) (tildify-test--test '(html-mode sgml-mode) (tildify-test--example-html sentence sentence) (tildify-test--example-html sentence with-nbsp)))) @@ -81,7 +81,7 @@ after `tildify-buffer' is run." (ert-deftest tildify-test-xml () "Tests tildification in an XML document" (let* ((sentence (tildify-test--example-sentence " ")) - (with-nbsp (tildify-test--example-sentence " "))) + (with-nbsp (tildify-test--example-sentence " "))) (tildify-test--test '(nxml-mode) (tildify-test--example-html sentence sentence t) (tildify-test--example-html sentence with-nbsp t)))) commit 07556b0299b33b52cf352581bfdd6554819eea30 Author: Ulf Jasper Date: Mon Nov 17 21:17:06 2014 +0100 Fix bug#5433. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a4dec7a..696b384 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,6 @@ 2014-11-17 Ulf Jasper + Fix bug#5433. * calendar/icalendar.el (icalendar-export-alarms): New customizable variable. (icalendar-export-region): Export alarms as specified in commit 9e35ff6bcf9c52fb295b4eb5d4dcde37b6a60b65 Merge: cc5519d 5813f93 Author: Ulf Jasper Date: Mon Nov 17 21:06:33 2014 +0100 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs commit cc5519db12f554a40591ac8a7f4febe17a3bd53b Merge: 62243cb 16b5f50 Author: Ulf Jasper Date: Mon Nov 17 21:00:24 2014 +0100 Merge branch 'uj-icalendar-bug#5433' commit 16b5f507688b32b78843620417bb2176b3131752 Author: Ulf Jasper Date: Mon Nov 17 20:51:26 2014 +0100 New option `icalendar-export-alarms'. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9d22d76..2bca643 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2014-11-17 Ulf Jasper + + * calendar/icalendar.el (icalendar-export-alarms): New + customizable variable. + (icalendar-export-region): Export alarms as specified in + `icalendar-export-alarms'. + (icalendar--create-ical-alarm, icalendar--do-create-ical-alarm): + New functions for exporting alarms. + 2014-11-16 Ulf Jasper * calendar/icalendar.el (icalendar--convert-tz-offset): Return diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index dddcc64..af9b2a4 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -270,8 +270,7 @@ other sexp entries are enumerated in any case." (defcustom icalendar-export-alarms nil - "Determine if and how alarms are included in exported diary events. -FIXME" + "Determine if and how alarms are included in exported diary events." :version "25.1" :type '(choice (const :tag "Do not include alarms in export" nil) @@ -304,7 +303,6 @@ FIXME" ;; ====================================================================== (require 'calendar) (require 'diary-lib) -(require 'appt) ;; ====================================================================== ;; misc @@ -1115,7 +1113,7 @@ FExport diary data into iCalendar file: ") (icalendar--create-uid entry-full contents)))) (setq alarm (icalendar--create-ical-alarm - (car contents-n-summary)))) + (cdr contents-n-summary)))) (setq result (concat result header contents alarm "\nEND:VEVENT"))) (if (consp cns-cons-or-list) @@ -1292,33 +1290,41 @@ Returns an alist." (if uid (cons 'uid uid) nil)))))))) (defun icalendar--create-ical-alarm (summary) + "Return VALARM blocks for the given SUMMARY." (when icalendar-export-alarms (let* ((advance-time (car icalendar-export-alarms)) (alarm-specs (cadr icalendar-export-alarms)) (fun (lambda (spec) (icalendar--do-create-ical-alarm advance-time spec summary)))) - (mapconcat fun alarm-specs "\n")))) + (mapconcat fun alarm-specs "")))) (defun icalendar--do-create-ical-alarm (advance-time alarm-spec summary) + "Return a VALARM block. +Argument ADVANCE-TIME is a number giving the time when the alarm +fires (minutes before the respective event). Argument ALARM-SPEC +is a list which must be one of '(audio), '(display) or +'(email (ADDRESS1 ...)), see `icalendar-export-alarms'. Argument +SUMMARY is a string which contains a short description for the +alarm." (let* ((action (car alarm-spec)) - (act (format "ACTION:%s\n" + (act (format "\nACTION:%s" (cdr (assoc action '((audio . "AUDIO") (display . "DISPLAY") (email . "EMAIL")))))) - (tri (format "TRIGGER:-PT%dM\n" advance-time)) + (tri (format "\nTRIGGER:-PT%dM" advance-time)) (des (if (memq action '(display email)) - (format "DESCRIPTION:%s\n" summary) + (format "\nDESCRIPTION:%s" summary) "")) (sum (if (eq action 'email) - (format "SUMMARY:%s\n" summary) + (format "\nSUMMARY:%s" summary) "")) (att (if (eq action 'email) (mapconcat (lambda (i) - (format "ATTENDEE:MAILTO:%s\n" i)) + (format "\nATTENDEE:MAILTO:%s" i)) (cadr alarm-spec) "") ""))) - (concat "BEGIN:VALARM\n" act tri des sum att "END:VALARM"))) + (concat "\nBEGIN:VALARM" act tri des sum att "\nEND:VALARM"))) ;; subroutines for icalendar-export-region (defun icalendar--convert-ordinary-to-ical (nonmarker entry-main) diff --git a/test/ChangeLog b/test/ChangeLog index 4a6f005..5290ef3 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,11 @@ +2014-11-17 Ulf Jasper + + * automated/icalendar-tests.el (icalendar-tests--test-export): New + optional parameter `alarms'. + (icalendar-export-alarms): New test for exporting icalendar + alarms. + (icalendar-tests--test-cycle): Let `icalendar-export-alarms' be nil. + 2014-11-16 Ulf Jasper * automated/icalendar-tests.el (icalendar--parse-vtimezone): Add diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 3e2fecf..ddff155 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -503,33 +503,25 @@ END:VEVENT ;; restore time-zone even if something went terribly wrong (setenv "TZ" tz))) ) -(ert-deftest icalendar--create-ical-alarm () - "Test `icalendar--create-ical-alarms'." - (let ((icalendar-export-alarms)) - ;; testcase: no alarms - (setq icalendar-export-alarm nil) - (should (equal nil - (icalendar--create-ical-alarm "sumsum"))))) - - ;; ====================================================================== ;; Export tests ;; ====================================================================== (defun icalendar-tests--test-export (input-iso input-european input-american - expected-output) + expected-output &optional alarms) "Perform an export test. Argument INPUT-ISO iso style diary string. Argument INPUT-EUROPEAN european style diary string. Argument INPUT-AMERICAN american style diary string. Argument EXPECTED-OUTPUT expected iCalendar result string. +Optional argument ALARMS the value of `icalendar-export-alarms' for this test. European style input data must use german month names. American and ISO style input data must use english month names." (let ((tz (getenv "TZ")) (calendar-date-style 'iso) (icalendar-recurring-start-year 2000) - (icalendar-export-alarms nil)) + (icalendar-export-alarms alarms)) (unwind-protect (progn ;;; (message "Current time zone: %s" (current-time-zone)) @@ -763,6 +755,97 @@ RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706 SUMMARY:block no end time ")) +(ert-deftest icalendar-export-alarms () + "Perform export test with different settings for exporting alarms." + ;; no alarm + (icalendar-tests--test-export + "2014 Nov 17 19:30 no alarm" + "17 Nov 2014 19:30 no alarm" + "Nov 17 2014 19:30 no alarm" + "DTSTART;VALUE=DATE-TIME:20141117T193000 +DTEND;VALUE=DATE-TIME:20141117T203000 +SUMMARY:no alarm +" + nil) + + ;; 10 minutes in advance, audio + (icalendar-tests--test-export + "2014 Nov 17 19:30 audio alarm" + "17 Nov 2014 19:30 audio alarm" + "Nov 17 2014 19:30 audio alarm" + "DTSTART;VALUE=DATE-TIME:20141117T193000 +DTEND;VALUE=DATE-TIME:20141117T203000 +SUMMARY:audio alarm +BEGIN:VALARM +ACTION:AUDIO +TRIGGER:-PT10M +END:VALARM +" + '(10 ((audio)))) + + ;; 20 minutes in advance, display + (icalendar-tests--test-export + "2014 Nov 17 19:30 display alarm" + "17 Nov 2014 19:30 display alarm" + "Nov 17 2014 19:30 display alarm" + "DTSTART;VALUE=DATE-TIME:20141117T193000 +DTEND;VALUE=DATE-TIME:20141117T203000 +SUMMARY:display alarm +BEGIN:VALARM +ACTION:DISPLAY +TRIGGER:-PT20M +DESCRIPTION:display alarm +END:VALARM +" + '(20 ((display)))) + + ;; 66 minutes in advance, email + (icalendar-tests--test-export + "2014 Nov 17 19:30 email alarm" + "17 Nov 2014 19:30 email alarm" + "Nov 17 2014 19:30 email alarm" + "DTSTART;VALUE=DATE-TIME:20141117T193000 +DTEND;VALUE=DATE-TIME:20141117T203000 +SUMMARY:email alarm +BEGIN:VALARM +ACTION:EMAIL +TRIGGER:-PT66M +DESCRIPTION:email alarm +SUMMARY:email alarm +ATTENDEE:MAILTO:att.one@email.com +ATTENDEE:MAILTO:att.two@email.com +END:VALARM +" + '(66 ((email ("att.one@email.com" "att.two@email.com"))))) + + ;; 2 minutes in advance, all alarms + (icalendar-tests--test-export + "2014 Nov 17 19:30 all alarms" + "17 Nov 2014 19:30 all alarms" + "Nov 17 2014 19:30 all alarms" + "DTSTART;VALUE=DATE-TIME:20141117T193000 +DTEND;VALUE=DATE-TIME:20141117T203000 +SUMMARY:all alarms +BEGIN:VALARM +ACTION:EMAIL +TRIGGER:-PT2M +DESCRIPTION:all alarms +SUMMARY:all alarms +ATTENDEE:MAILTO:att.one@email.com +ATTENDEE:MAILTO:att.two@email.com +END:VALARM +BEGIN:VALARM +ACTION:AUDIO +TRIGGER:-PT2M +END:VALARM +BEGIN:VALARM +ACTION:DISPLAY +TRIGGER:-PT2M +DESCRIPTION:all alarms +END:VALARM +" + '(2 ((email ("att.one@email.com" "att.two@email.com")) (audio) (display))))) + ;; ====================================================================== ;; Import tests ;; ====================================================================== commit 5813f93cab1a81eba6eef735add5ca7cb1d15e8e Author: Glenn Morris Date: Mon Nov 17 13:55:02 2014 -0500 * test/automated/occur-tests.el (occur-tests): Update for output change re control-chars. diff --git a/test/ChangeLog b/test/ChangeLog index 42fcd8e..fb00410 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -2,6 +2,7 @@ * automated/occur-tests.el (occur-test-case, occur-test-create): In case of failure, show the actual string, rather than just nil. + (occur-tests): Update for apparent change in output re control-chars. 2014-11-17 Ulf Jasper diff --git a/test/automated/occur-tests.el b/test/automated/occur-tests.el index c00b71d..5b90dab 100644 --- a/test/automated/occur-tests.el +++ b/test/automated/occur-tests.el @@ -52,7 +52,7 @@ a a a " "\ -2 matches for \"a^Ja\" in buffer: *test-occur* +2 matches for \"a\na\" in buffer: *test-occur* 1:a :a 3:a @@ -68,7 +68,7 @@ c a b " "\ -2 matches for \"a^Jb\" in buffer: *test-occur* +2 matches for \"a\nb\" in buffer: *test-occur* 1:a :b 4:a @@ -82,7 +82,7 @@ c a " "\ -2 matches for \"a^J\" in buffer: *test-occur* +2 matches for \"a\n\" in buffer: *test-occur* 1:a : 4:a @@ -97,7 +97,7 @@ d ex fx " "\ -2 matches for \"x^J.x^J\" in buffer: *test-occur* +2 matches for \"x\n.x\n\" in buffer: *test-occur* 1:ax :bx :c @@ -232,7 +232,7 @@ i jx kx " "\ -3 matches for \"x^J.x\" in buffer: *test-occur* +3 matches for \"x\n.x\" in buffer: *test-occur* 1:ax :bx :c @@ -256,7 +256,7 @@ f gx hx " "\ -2 matches for \"x^J.x\" in buffer: *test-occur* +2 matches for \"x\n.x\" in buffer: *test-occur* 1:ax :bx :c commit 0eaf98e85afd670332454a089ad982190f86e05f Author: Lars Magne Ingebrigtsen Date: Mon Nov 17 19:47:18 2014 +0100 Peder Klingenberg has signed papers diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c052a68..912b69a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -107,7 +107,7 @@ * progmodes/python.el (python-indent-region): Use python-indent-line and skip special cases. (Bug#18843) -2014-11-16 Peder O. Klingenberg (tiny change) +2014-11-16 Peder O. Klingenberg * mail/emacsbug.el (report-emacs-bug): Make a better guess at envelope-from when reporting through sendmail (bug#19054). commit 29f81b95885dfce4ef92b93c330cf9057d14745e Author: Lars Magne Ingebrigtsen Date: Mon Nov 17 19:46:51 2014 +0100 * lisp/bindings.el (search-map): Move `eww-search-words' to `M-s M-w'. diff --git a/etc/NEWS b/etc/NEWS index cb34e9b..ecbbf74 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -51,7 +51,7 @@ Use './configure PKG_CONFIG=/full/name/of/pkg-config' if you need to. ** C-h l now also lists the commands that were run. -** The new M-s M-s key binding uses eww to search the web for the +** The new M-s M-w key binding uses eww to search the web for the text in the region. ** M-x suggests shorthands and ignores obsolete commands for completion. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c30a2dd..c052a68 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-11-17 Lars Magne Ingebrigtsen + + * bindings.el (search-map): Move `eww-search-words' to `M-s M-w'. + 2014-11-17 Paul Eggert Port new time stamp handling to old Emacs and to XEmacs. diff --git a/lisp/bindings.el b/lisp/bindings.el index 46ff522..1107740 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -926,7 +926,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key esc-map "s" search-map) (define-key search-map "o" 'occur) -(define-key search-map "\M-s" 'eww-search-words) +(define-key search-map "\M-w" 'eww-search-words) (define-key search-map "hr" 'highlight-regexp) (define-key search-map "hp" 'highlight-phrase) (define-key search-map "hl" 'highlight-lines-matching-regexp) commit 83087df9492f4a16c835664aa39d0b8a7756d4bb Author: Glenn Morris Date: Mon Nov 17 13:39:56 2014 -0500 Improve output of occur-tests in case of failure * test/automated/occur-tests.el (occur-test-case, occur-test-create): In case of failure, show the actual string, rather than just nil. diff --git a/test/ChangeLog b/test/ChangeLog index 47bbfb3..42fcd8e 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2014-11-17 Glenn Morris + + * automated/occur-tests.el (occur-test-case, occur-test-create): + In case of failure, show the actual string, rather than just nil. + 2014-11-17 Ulf Jasper * automated/icalendar-tests.el (icalendar-tests--test-import): diff --git a/test/automated/occur-tests.el b/test/automated/occur-tests.el index b15e3dc..c00b71d 100644 --- a/test/automated/occur-tests.el +++ b/test/automated/occur-tests.el @@ -321,7 +321,6 @@ Each element has the format: (let ((regexp (nth 0 test)) (nlines (nth 1 test)) (input-buffer-string (nth 2 test)) - (output-buffer-string (nth 3 test)) (temp-buffer (get-buffer-create " *test-occur*"))) (unwind-protect (save-window-excursion @@ -329,9 +328,8 @@ Each element has the format: (erase-buffer) (insert input-buffer-string) (occur regexp nlines) - (equal output-buffer-string - (with-current-buffer "*Occur*" - (buffer-string))))) + (with-current-buffer "*Occur*" + (buffer-substring-no-properties (point-min) (point-max))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) @@ -343,7 +341,8 @@ Each element has the format: `(ert-deftest ,testname () ,testdoc (let (occur-hook) - (should (occur-test-case (nth ,n occur-tests)))))))) + (should (equal (occur-test-case (nth ,n occur-tests)) + (nth 3 (nth ,n occur-tests))))))))) (dotimes (i (length occur-tests)) (occur-test-create i)) commit 62243cb96f133581157f6eafa934b5b7ca4cc065 Author: Ulf Jasper Date: Mon Nov 17 16:53:09 2014 +0100 icalendar: Add another test case for no-dst timezones. diff --git a/test/ChangeLog b/test/ChangeLog index 4a6f005..47bbfb3 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2014-11-17 Ulf Jasper + + * automated/icalendar-tests.el (icalendar-tests--test-import): + Mention timezone in doc string. Clean up. + (icalendar-real-world): Add another test case for no-dst + timezones. + 2014-11-16 Ulf Jasper * automated/icalendar-tests.el (icalendar--parse-vtimezone): Add diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 23afb14..b45806e 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -763,15 +763,14 @@ SUMMARY:block no end time Argument INPUT icalendar event string. Argument EXPECTED-ISO expected iso style diary string. Argument EXPECTED-EUROPEAN expected european style diary string. -Argument EXPECTED-AMERICAN expected american style diary string." +Argument EXPECTED-AMERICAN expected american style diary string. +During import test the timezone is set to Central European Time." (let ((timezone (getenv "TZ"))) (unwind-protect (progn -;;; (message "Current time zone: %s" (current-time-zone)) ;; Use this form so as not to rely on system tz database. ;; Eg hydra.nixos.org. (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") -;;; (message "Current time zone: %s" (current-time-zone)) (with-temp-buffer (if (string-match "^BEGIN:VCALENDAR" input) (insert input) @@ -1425,6 +1424,47 @@ END:VCALENDAR" UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9 ") + ;; created with http://apps.marudot.com/ical/ + (icalendar-tests--test-import + "BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//www.marudot.com//iCal Event Maker +X-WR-CALNAME:Test +CALSCALE:GREGORIAN +BEGIN:VTIMEZONE +TZID:Asia/Tehran +TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Tehran +X-LIC-LOCATION:Asia/Tehran +BEGIN:STANDARD +TZOFFSETFROM:+0330 +TZOFFSETTO:+0330 +TZNAME:IRST +DTSTART:19700101T000000 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +DTSTAMP:20141116T171439Z +UID:20141116T171439Z-678877132@marudot.com +DTSTART;TZID=\"Asia/Tehran\":20141116T070000 +DTEND;TZID=\"Asia/Tehran\":20141116T080000 +SUMMARY:NoDST +DESCRIPTION:Test event from timezone without DST +LOCATION:Everywhere +END:VEVENT +END:VCALENDAR" + nil + "&16/11/2014 04:30-05:30 NoDST + Desc: Test event from timezone without DST + Location: Everywhere + UID: 20141116T171439Z-678877132@marudot.com +" + "&11/16/2014 04:30-05:30 NoDST + Desc: Test event from timezone without DST + Location: Everywhere + UID: 20141116T171439Z-678877132@marudot.com +") + + ;; 2003-06-18 a (icalendar-tests--test-import "DTSTAMP:20030618T195512Z commit b7cce56d7d8aa213259b4582c39970e331b16fc6 Author: Ulf Jasper Date: Mon Nov 17 16:44:52 2014 +0100 intermediate commit diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index e00976d..dddcc64 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -267,6 +267,7 @@ other sexp entries are enumerated in any case." :type 'boolean :group 'icalendar) + (defcustom icalendar-export-alarms nil "Determine if and how alarms are included in exported diary events. commit 6f20cde0117a181159eed4a1992ed8c536d8ecce Author: Ulf Jasper Date: Sat Nov 15 20:54:28 2014 +0100 alarm export, first step diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index cdda8f0..e00976d 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -270,28 +270,22 @@ other sexp entries are enumerated in any case." (defcustom icalendar-export-alarms nil "Determine if and how alarms are included in exported diary events. -FIXME -... appt-display-format -... appt-audible -.... appt-message-warning-time -... appt-warning-time-regexp -" +FIXME" :version "25.1" - :type '(choice (const :tag "Do not include alarms in export" nil) - (const :tag "Apply emacs defaults FIXME" 'default) + :type '(choice (const :tag "Do not include alarms in export" + nil) (list :tag "Create alarms in exported diary entries" (integer :tag "Advance time (minutes)" - ;; FIXME - :value appt-message-warning-time) - (choice :tag "Alarm type" - (list :tag "Audio" - (string :tag "Audio file")) - (cons :tag "Display" - (string :tag "Description")) - (list :tag "Email" - (string :tag "Description") - (string :tag "Summary") - (string :tag "Attendees"))))) + :value 10) + (set :tag "Alarm type" + (list :tag "Audio" + (const audio :tag "Audio")) + (list :tag "Display" + (const display :tag "Display")) + (list :tag "Email" + (const email) + (repeat :tag "Attendees" + (string :tag "Email")))))) :group 'icalendar) @@ -1055,6 +1049,7 @@ FExport diary data into iCalendar file: ") (header "") (contents-n-summary) (contents) + (alarm) (found-error nil) (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol) "?")) @@ -1117,8 +1112,10 @@ FExport diary data into iCalendar file: ") (setq header (concat "\nBEGIN:VEVENT\nUID:" (or uid (icalendar--create-uid - entry-full contents))))) - (setq result (concat result header contents + entry-full contents)))) + (setq alarm (icalendar--create-ical-alarm + (car contents-n-summary)))) + (setq result (concat result header contents alarm "\nEND:VEVENT"))) (if (consp cns-cons-or-list) (list cns-cons-or-list) @@ -1293,6 +1290,35 @@ Returns an alist." (if url (cons 'url url) nil) (if uid (cons 'uid uid) nil)))))))) +(defun icalendar--create-ical-alarm (summary) + (when icalendar-export-alarms + (let* ((advance-time (car icalendar-export-alarms)) + (alarm-specs (cadr icalendar-export-alarms)) + (fun (lambda (spec) + (icalendar--do-create-ical-alarm advance-time spec summary)))) + (mapconcat fun alarm-specs "\n")))) + +(defun icalendar--do-create-ical-alarm (advance-time alarm-spec summary) + (let* ((action (car alarm-spec)) + (act (format "ACTION:%s\n" + (cdr (assoc action '((audio . "AUDIO") + (display . "DISPLAY") + (email . "EMAIL")))))) + (tri (format "TRIGGER:-PT%dM\n" advance-time)) + (des (if (memq action '(display email)) + (format "DESCRIPTION:%s\n" summary) + "")) + (sum (if (eq action 'email) + (format "SUMMARY:%s\n" summary) + "")) + (att (if (eq action 'email) + (mapconcat (lambda (i) + (format "ATTENDEE:MAILTO:%s\n" i)) + (cadr alarm-spec) "") + ""))) + + (concat "BEGIN:VALARM\n" act tri des sum att "END:VALARM"))) + ;; subroutines for icalendar-export-region (defun icalendar--convert-ordinary-to-ical (nonmarker entry-main) "Convert \"ordinary\" diary entry to iCalendar format. diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 23afb14..3e2fecf 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -503,6 +503,15 @@ END:VEVENT ;; restore time-zone even if something went terribly wrong (setenv "TZ" tz))) ) +(ert-deftest icalendar--create-ical-alarm () + "Test `icalendar--create-ical-alarms'." + (let ((icalendar-export-alarms)) + ;; testcase: no alarms + (setq icalendar-export-alarm nil) + (should (equal nil + (icalendar--create-ical-alarm "sumsum"))))) + + ;; ====================================================================== ;; Export tests ;; ====================================================================== @@ -519,7 +528,8 @@ European style input data must use german month names. American and ISO style input data must use english month names." (let ((tz (getenv "TZ")) (calendar-date-style 'iso) - (icalendar-recurring-start-year 2000)) + (icalendar-recurring-start-year 2000) + (icalendar-export-alarms nil)) (unwind-protect (progn ;;; (message "Current time zone: %s" (current-time-zone)) @@ -1286,7 +1296,8 @@ Argument INPUT icalendar event string." (icalendar-import-format-status "\n Status: %s") (icalendar-import-format-url "\n URL: %s") (icalendar-import-format-class "\n Class: %s") - (icalendar-import-format-class "\n UID: %s")) + (icalendar-import-format-class "\n UID: %s") + (icalendar-export-alarms nil)) (dolist (calendar-date-style '(iso european american)) (icalendar-tests--do-test-cycle))))) commit 0df06a3ac574ddd17cdf82c0f1f236711c768305 Author: Ulf Jasper Date: Sat Nov 15 13:49:28 2014 +0100 intermediate commit diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 9dba6ff..cdda8f0 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -267,6 +267,34 @@ other sexp entries are enumerated in any case." :type 'boolean :group 'icalendar) +(defcustom icalendar-export-alarms + nil + "Determine if and how alarms are included in exported diary events. +FIXME +... appt-display-format +... appt-audible +.... appt-message-warning-time +... appt-warning-time-regexp +" + :version "25.1" + :type '(choice (const :tag "Do not include alarms in export" nil) + (const :tag "Apply emacs defaults FIXME" 'default) + (list :tag "Create alarms in exported diary entries" + (integer :tag "Advance time (minutes)" + ;; FIXME + :value appt-message-warning-time) + (choice :tag "Alarm type" + (list :tag "Audio" + (string :tag "Audio file")) + (cons :tag "Display" + (string :tag "Description")) + (list :tag "Email" + (string :tag "Description") + (string :tag "Summary") + (string :tag "Attendees"))))) + :group 'icalendar) + + (defvar icalendar-debug nil "Enable icalendar debug messages.") @@ -281,6 +309,7 @@ other sexp entries are enumerated in any case." ;; ====================================================================== (require 'calendar) (require 'diary-lib) +(require 'appt) ;; ====================================================================== ;; misc @@ -1053,7 +1082,7 @@ FExport diary data into iCalendar file: ") (condition-case error-val (progn (setq cns-cons-or-list - (icalendar--convert-to-ical nonmarker entry-main)) + (icalendar--convert-to-ical nonmarker entry-main)) (setq other-elements (icalendar--parse-summary-and-rest entry-full)) (mapc (lambda (contents-n-summary)