------------------------------------------------------------ revno: 117281 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2014-06-05 22:35:17 -0400 message: * lisp/mouse.el (mouse-posn-property): Ignore buffer position info when the even happened elsewhere. * src/keyboard.c (make_lispy_position): Don't include a buffer position in mode/header-line mouse events. diff: === modified file 'lisp/mouse.el' --- lisp/mouse.el 2014-06-02 00:18:22 +0000 +++ lisp/mouse.el 2014-06-06 02:35:17 +0000 @@ -684,10 +684,11 @@ (str (posn-string pos))) (or (and str (get-text-property (cdr str) property (car str))) - ;; FIXME: mouse clicks on the mode-line come with a position in - ;; (nth 5). Maybe we should change the C code instead so that - ;; mouse-clicks don't include a position there! - (and pt (not (memq (posn-area pos) '(mode-line header-line))) + ;; Mouse clicks in the fringe come with a position in + ;; (nth 5). This is useful but is not exactly where we clicked, so + ;; don't look up that position's properties! + (and pt (not (memq (posn-area pos) '(left-fringe right-fringe + left-margin right-margin))) (get-char-property pt property w)))) (get-char-property pos property))) === modified file 'src/ChangeLog' --- src/ChangeLog 2014-06-06 02:22:40 +0000 +++ src/ChangeLog 2014-06-06 02:35:17 +0000 @@ -1,5 +1,8 @@ 2014-06-06 Stefan Monnier + * keyboard.c (make_lispy_position): Don't include a buffer position in + mode/header-line mouse events. + * keyboard.c (read_char): Handle (t . ) in the second use of Vunread_command_events (bug#17650). === modified file 'src/keyboard.c' --- src/keyboard.c 2014-06-06 02:22:40 +0000 +++ src/keyboard.c 2014-06-06 02:35:17 +0000 @@ -2465,7 +2465,7 @@ inside universal-argument. */ if (CONSP (c) && EQ (XCAR (c), Qt)) - c = XCDR (c); + c = XCDR (c); else reread = true; @@ -5228,7 +5228,7 @@ /* It's a click in window WINDOW at frame coordinates (X,Y) */ struct window *w = XWINDOW (window); Lisp_Object string_info = Qnil; - ptrdiff_t textpos = -1; + ptrdiff_t textpos = 0; int col = -1, row = -1; int dx = -1, dy = -1; int width = -1, height = -1; @@ -5263,9 +5263,7 @@ &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - textpos = (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->contents)) - ? PT : marker_position (w->pointm); + textpos = -1; xret = wx; yret = wy; @@ -5333,7 +5331,7 @@ /* For clicks in the text area, fringes, or margins, call buffer_posn_from_coords to extract TEXTPOS, the buffer position nearest to the click. */ - if (textpos < 0) + if (!textpos) { Lisp_Object string2, object2 = Qnil; struct display_pos p; @@ -5384,15 +5382,15 @@ } #endif - /* Object info */ + /* Object info. */ extra_info = list3 (object, Fcons (make_number (dx), make_number (dy)), Fcons (make_number (width), make_number (height))); - /* String info */ + /* String info. */ extra_info = Fcons (string_info, - Fcons (make_number (textpos), + Fcons (textpos < 0 ? Qnil : make_number (textpos), Fcons (Fcons (make_number (col), make_number (row)), extra_info))); ------------------------------------------------------------ revno: 117280 fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17650 committer: Stefan Monnier branch nick: trunk timestamp: Thu 2014-06-05 22:22:40 -0400 message: * src/keyboard.c (read_char): Handle (t . ) in the second use of Vunread_command_events. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-06-06 01:11:26 +0000 +++ src/ChangeLog 2014-06-06 02:22:40 +0000 @@ -1,7 +1,12 @@ +2014-06-06 Stefan Monnier + + * keyboard.c (read_char): Handle (t . ) in the second use of + Vunread_command_events (bug#17650). + 2014-06-06 Dmitry Antipov - * xterm.c (x_setup_pointer_blanking): Conditionally - probe Xfixes until this stuff is stabilized (Bug#17609). + * xterm.c (x_setup_pointer_blanking): + Conditionally probe Xfixes until this stuff is stabilized (Bug#17609). 2014-06-05 Dmitry Antipov @@ -19,14 +24,13 @@ * nsterm.h (ns_popup_dialog): Adjust prototype. * nsterm.m (ns_create_terminal): * w32term.c (w32_create_terminal): - * xterm.c (x_create_terminal) [USE_X_TOOLKIT || USE_GTK]: Setup - popup_dialog_hook. + * xterm.c (x_create_terminal) [USE_X_TOOLKIT || USE_GTK]: + Setup popup_dialog_hook. 2014-06-04 Eli Zaretskii * w32heap.c (report_temacs_memory_usage): Improve the report by - reporting the large blocks that are actually occupied at dump - time. + reporting the large blocks that are actually occupied at dump time. * w32console.c (initialize_w32_display): Set the console menu_show_hook, otherwise TTY menus are broken on w32. @@ -86,8 +90,7 @@ 2014-06-03 Eli Zaretskii * w32heap.c (DUMPED_HEAP_SIZE): Move from w32heap.h. Don't use - HEAPSIZE; instead, define separate values for the 32- and 64-bit - builds. + HEAPSIZE; instead, define separate values for the 32- and 64-bit builds. (calloc): Don't undef, it is never defined. (HEAP_ENTRY_SHIFT): Remove unused macro. @@ -103,16 +106,15 @@ 2014-06-03 Paul Eggert - * process.c (wait_reading_process_output): Omit incorrect test - of p->infd against zero. Add easserts for infd having a plausible - value. + * process.c (wait_reading_process_output): Omit incorrect test of + p->infd against zero. Add easserts for infd having a plausible value. 2014-06-02 Dmitry Antipov Adjust to match recent lwlib changes. - * menu.h (xmalloc_widget_value): Replaced by ... + * menu.h (xmalloc_widget_value): Replace by ... (make_widget_value): ... new prototype. - * menu.c (xmalloc_widget_value): Replaced by ... + * menu.c (xmalloc_widget_value): Replace by ... (make_widget_value): ... new function. (free_menubar_widget_value_tree, digest_single_submenu): Adjust users. * gtkutil.c (malloc_widget_value, free_widget_value): @@ -272,8 +274,8 @@ * w32heap.c (report_temacs_memory_usage): New function. - * unexw32.c (unexec) [ENABLE_CHECKING]: Call - report_temacs_memory_usage. + * unexw32.c (unexec) [ENABLE_CHECKING]: + Call report_temacs_memory_usage. * w32heap.h (report_temacs_memory_usage): Add prototype. @@ -372,8 +374,7 @@ * image.c (free_image): Undef free for Windows because it is redirected to our private version. - * unexw32.c (COPY_PROC_CHUNK): Use %p format for 64bits - compatibility. + * unexw32.c (COPY_PROC_CHUNK): Use %p format for 64bits compatibility. (copy_executable_and_dump_data): Remove dumping the heap section. (unexec): Restore using_dynamic_heap after dumping. @@ -401,8 +402,7 @@ 2014-05-26 Eli Zaretskii - * w32.c (_ANONYMOUS_UNION, _ANONYMOUS_STRUCT): Define only if - undefined. + * w32.c (_ANONYMOUS_UNION, _ANONYMOUS_STRUCT): Define only if undefined. 2014-05-26 Ken Brown @@ -491,7 +491,7 @@ was moved to Fgarbage_collect. (Fgarbage_collect): Calculate the end address of the stack portion that needs to be examined by mark_stack, and pass that address to - garbage_collect_1, which will pass it to mark_stack. See + garbage_collect_1, which will pass it to mark_stack. See http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00270.html for more details about the underlying problems. In particular, this avoids dumping Emacs with the large hash-table whose value is === modified file 'src/keyboard.c' --- src/keyboard.c 2014-06-05 06:24:54 +0000 +++ src/keyboard.c 2014-06-06 02:22:40 +0000 @@ -2434,7 +2434,6 @@ retry: - reread = 0; if (CONSP (Vunread_post_input_method_events)) { c = XCAR (Vunread_post_input_method_events); @@ -2448,9 +2447,12 @@ && NILP (XCDR (c))) c = XCAR (c); - reread = 1; + reread = true; goto reread_first; } + else + reread = false; + if (CONSP (Vunread_command_events)) { @@ -2459,17 +2461,13 @@ c = XCAR (Vunread_command_events); Vunread_command_events = XCDR (Vunread_command_events); - reread = 1; - /* Undo what sit-for did when it unread additional keys inside universal-argument. */ - if (CONSP (c) - && EQ (XCAR (c), Qt)) - { - reread = 0; + if (CONSP (c) && EQ (XCAR (c), Qt)) c = XCDR (c); - } + else + reread = true; /* Undo what read_char_x_menu_prompt did when it unread additional keys returned by Fx_popup_menu. */ @@ -2503,7 +2501,7 @@ && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))) && NILP (XCDR (c))) c = XCAR (c); - reread = 1; + reread = true; goto reread_for_input_method; } @@ -2844,6 +2842,11 @@ { c = XCAR (Vunread_command_events); Vunread_command_events = XCDR (Vunread_command_events); + + if (CONSP (c) && EQ (XCAR (c), Qt)) + c = XCDR (c); + else + reread = true; } /* Read something from current KBOARD's side queue, if possible. */ @@ -2897,8 +2900,8 @@ { c = read_decoded_event_from_main_queue (end_time, local_getcjmp, prev_event, used_mouse_menu); - if (NILP(c) && end_time && - timespec_cmp (*end_time, current_timespec ()) <= 0) + if (NILP (c) && end_time + && timespec_cmp (*end_time, current_timespec ()) <= 0) { goto exit; } ------------------------------------------------------------ revno: 117279 committer: Dmitry Antipov branch nick: trunk timestamp: Fri 2014-06-06 05:11:26 +0400 message: * xterm.c (x_setup_pointer_blanking): Conditionally probe Xfixes until this stuff is stabilized (Bug#17609). diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-06-05 06:24:54 +0000 +++ src/ChangeLog 2014-06-06 01:11:26 +0000 @@ -1,3 +1,8 @@ +2014-06-06 Dmitry Antipov + + * xterm.c (x_setup_pointer_blanking): Conditionally + probe Xfixes until this stuff is stabilized (Bug#17609). + 2014-06-05 Dmitry Antipov * keyboard.c, process.c: Do not define POLL_FOR_INPUT here === modified file 'src/xterm.c' --- src/xterm.c 2014-06-04 14:59:09 +0000 +++ src/xterm.c 2014-06-06 01:11:26 +0000 @@ -9781,7 +9781,9 @@ static void x_setup_pointer_blanking (struct x_display_info *dpyinfo) { - if (x_probe_xfixes_extension (dpyinfo->display)) + /* FIXME: the brave tester should set EMACS_XFIXES because we're suspecting + X server bug, see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17609. */ + if (egetenv ("EMACS_XFIXES") && x_probe_xfixes_extension (dpyinfo->display)) dpyinfo->toggle_visible_pointer = xfixes_toggle_visible_pointer; else { ------------------------------------------------------------ revno: 117278 committer: Mario Lang branch nick: trunk timestamp: Fri 2014-06-06 02:39:22 +0200 message: * emacs-lisp/tabulated-list.el (tabulated-list-print): Only call `recenter' if `current-buffer' is equal to `window-buffer'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 17:08:18 +0000 +++ lisp/ChangeLog 2014-06-06 00:39:22 +0000 @@ -1,3 +1,8 @@ +2014-06-06 Mario Lang + + * emacs-lisp/tabulated-list.el (tabulated-list-print): Only call + `recenter' if `current-buffer' is equal to `window-buffer'. + 2014-06-05 Leo Liu * emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's. === modified file 'lisp/emacs-lisp/tabulated-list.el' --- lisp/emacs-lisp/tabulated-list.el 2014-01-01 07:43:34 +0000 +++ lisp/emacs-lisp/tabulated-list.el 2014-06-06 00:39:22 +0000 @@ -323,7 +323,8 @@ (if saved-pt (progn (goto-char saved-pt) (move-to-column saved-col) - (recenter)) + (when (eq (window-buffer) (current-buffer)) + (recenter))) (goto-char (point-min))))) (defun tabulated-list-print-entry (id cols) ------------------------------------------------------------ revno: 117277 committer: Leo Liu branch nick: trunk timestamp: Fri 2014-06-06 07:08:59 +0800 message: * emacs-lisp/cl-macs.el (cl-macrolet): Simplify last change. diff: === modified file 'lisp/emacs-lisp/cl-macs.el' --- lisp/emacs-lisp/cl-macs.el 2014-06-05 17:08:18 +0000 +++ lisp/emacs-lisp/cl-macs.el 2014-06-05 23:08:59 +0000 @@ -1886,15 +1886,13 @@ cl-declarations body))) (if (cdr bindings) `(cl-macrolet (,(car bindings)) (cl-macrolet ,(cdr bindings) ,@body)) - (let ((progn-maybe (lambda (body) - (if (cdr body) (cons 'progn body) (car body))))) - (if (null bindings) (funcall progn-maybe body) - (let* ((name (caar bindings)) - (res (cl--transform-lambda (cdar bindings) name))) - (eval (car res)) - (macroexpand-all (funcall progn-maybe body) - (cons (cons name `(lambda ,@(cdr res))) - macroexpand-all-environment))))))) + (if (null bindings) (macroexp-progn body) + (let* ((name (caar bindings)) + (res (cl--transform-lambda (cdar bindings) name))) + (eval (car res)) + (macroexpand-all (macroexp-progn body) + (cons (cons name `(lambda ,@(cdr res))) + macroexpand-all-environment)))))) (defconst cl--old-macroexpand (if (and (boundp 'cl--old-macroexpand) ------------------------------------------------------------ revno: 117276 committer: Katsumi Yamaoka branch nick: trunk timestamp: Thu 2014-06-05 22:43:36 +0000 message: lisp/gnus/gnus-art.el (gnus-mime-buttonize-attachments-in-header): Improve criterion that finds parts to display diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2014-06-05 04:31:36 +0000 +++ lisp/gnus/ChangeLog 2014-06-05 22:43:36 +0000 @@ -3,6 +3,8 @@ * gnus-art.el (gnus-article-edit-part): Don't modifiy markers. (gnus-article-read-summary-keys): Don't bug out when there is no article in the summary buffer. + (gnus-mime-buttonize-attachments-in-header): + Improve criterion that finds parts to display. * gnus-art.el (gnus-mm-display-part): * mm-decode.el (mm-shr): === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2014-06-05 04:31:36 +0000 +++ lisp/gnus/gnus-art.el 2014-06-05 22:43:36 +0000 @@ -4994,6 +4994,9 @@ ',gnus-newsgroup-ignored-charsets)) (mbl mml-buffer-list)) (setq mml-buffer-list nil) + ;; A new text must be inserted before deleting existing ones + ;; at the end so as not to move existing markers of which + ;; the insertion type is t. (delete-region (point-min) (prog1 @@ -6370,7 +6373,7 @@ (setcar handle (caar handle)))) flat) flat)))) - (let ((case-fold-search t) buttons st handle) + (let ((case-fold-search t) buttons handle type st) (save-excursion (save-restriction (widen) @@ -6390,14 +6393,24 @@ (unless (and interactive buttons) ;; Find buttons. (setq buttons nil) - (dolist (handle (flattened-alist)) - (when (and (not (stringp (cadr handle))) - (or (equal (car (mm-handle-disposition - (cdr handle))) - "attachment") - (not (and (mm-inlinable-p (cdr handle)) - (mm-inlined-p (cdr handle)))))) - (push handle buttons))) + (dolist (button (flattened-alist)) + (setq handle (cdr button) + type (mm-handle-media-type handle)) + (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer) + (with-current-buffer gnus-summary-buffer + gnus-inhibit-images) + gnus-inhibit-images) + (string-match "\\`image/" type)) + (mm-inline-override-p handle) + (and (mm-handle-disposition handle) + (not (equal (car (mm-handle-disposition handle)) + "inline")) + (not (mm-attachment-override-p handle))) + (not (mm-automatic-display-p handle)) + (not (or (and (mm-inlinable-p handle) + (mm-inlined-p handle)) + (mm-automatic-external-display-p type)))) + (push button buttons))) (when buttons ;; Add header buttons. (article-goto-body) ------------------------------------------------------------ revno: 117275 committer: Dmitry Antipov branch nick: trunk timestamp: Thu 2014-06-05 21:31:41 +0400 message: * INSTALL: Mention SVG image support. diff: === modified file 'ChangeLog' --- ChangeLog 2014-06-05 08:03:22 +0000 +++ ChangeLog 2014-06-05 17:31:41 +0000 @@ -11,6 +11,7 @@ 2014-06-05 Dmitry Antipov * configure.ac (POLL_FOR_INPUT): Define with HAVE_WINDOW_SYSTEM. + * INSTALL: Mention SVG image support. 2014-06-05 Paul Eggert === modified file 'INSTALL' --- INSTALL 2014-06-05 00:34:34 +0000 +++ INSTALL 2014-06-05 17:31:41 +0000 @@ -169,6 +169,7 @@ X libjpeg for JPEG: http://www.ijg.org/ X libtiff for TIFF: http://www.remotesensing.org/libtiff/ X libgif for GIF: http://sourceforge.net/projects/giflib/ + librsvg2 for SVG: http://wiki.gnome.org/action/show/Projects/LibRsvg If you supply the appropriate --without-LIB option, 'configure' will omit the corresponding library from Emacs, even if that makes for a @@ -293,6 +294,7 @@ --without-tiff for TIFF image support --without-gif for GIF image support --without-png for PNG image support + --without-rsvg for SVG image support Use --without-toolkit-scroll-bars to disable Motif or Xaw3d scroll bars. ------------------------------------------------------------ revno: 117274 committer: Leo Liu branch nick: trunk timestamp: Fri 2014-06-06 01:08:18 +0800 message: * emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:42:07 +0000 +++ lisp/ChangeLog 2014-06-05 17:08:18 +0000 @@ -1,3 +1,7 @@ +2014-06-05 Leo Liu + + * emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's. + 2014-06-05 Michal Nazarewicz * textmodes/tildify.el (tildify-foreach-region-outside-env): New === modified file 'lisp/emacs-lisp/cl-macs.el' --- lisp/emacs-lisp/cl-macs.el 2014-05-04 19:37:56 +0000 +++ lisp/emacs-lisp/cl-macs.el 2014-06-05 17:08:18 +0000 @@ -1886,13 +1886,15 @@ cl-declarations body))) (if (cdr bindings) `(cl-macrolet (,(car bindings)) (cl-macrolet ,(cdr bindings) ,@body)) - (if (null bindings) (cons 'progn body) - (let* ((name (caar bindings)) - (res (cl--transform-lambda (cdar bindings) name))) - (eval (car res)) - (macroexpand-all (cons 'progn body) - (cons (cons name `(lambda ,@(cdr res))) - macroexpand-all-environment)))))) + (let ((progn-maybe (lambda (body) + (if (cdr body) (cons 'progn body) (car body))))) + (if (null bindings) (funcall progn-maybe body) + (let* ((name (caar bindings)) + (res (cl--transform-lambda (cdar bindings) name))) + (eval (car res)) + (macroexpand-all (funcall progn-maybe body) + (cons (cons name `(lambda ,@(cdr res))) + macroexpand-all-environment))))))) (defconst cl--old-macroexpand (if (and (boundp 'cl--old-macroexpand) ------------------------------------------------------------ revno: 117273 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:42:45 +0200 message: * tests/automated/tildify-tests.el (tildify-test--test): Optimise the test slightly by reusing the same temporary buffer across multiple test cases. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2014-06-05 14:42:07 +0000 +++ test/ChangeLog 2014-06-05 14:42:45 +0000 @@ -1,5 +1,9 @@ 2014-06-05 Michal Nazarewicz + * automated/tildify-tests.el (tildify-test--test): Optimise the test + slightly by reusing the same temporary buffer across multiple test + cases. + * automated/tildify-tests.el (tildify-test-find-env-end-re-bug) (tildify-test-find-env-group-index-bug): Update to support new signature of the `tildify-foreach-region-outside-env' function. === modified file 'test/automated/tildify-tests.el' --- test/automated/tildify-tests.el 2014-06-05 14:42:07 +0000 +++ test/automated/tildify-tests.el 2014-06-05 14:42:45 +0000 @@ -54,16 +54,16 @@ "Test tildify running in MODES. INPUT is the initial content of the buffer and EXPECTED is expected result after `tildify-buffer' is run." - (dolist (mode modes) - (with-temp-buffer + (with-temp-buffer + (dolist (mode modes) + (erase-buffer) (funcall mode) (let ((header (concat "Testing `tildify-buffer' in " (symbol-name mode) "\n"))) (insert header input) (tildify-buffer t) - (should (string-equal (concat header expected) (buffer-string))))) - (with-temp-buffer - (funcall mode) + (should (string-equal (concat header expected) (buffer-string)))) + (erase-buffer) (let ((header (concat "Testing `tildify-region' in " (symbol-name mode) "\n"))) (insert header input) ------------------------------------------------------------ revno: 117272 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:42:07 +0200 message: tildify.el: Rewrite `tildify-region' and co., add foreach function. * lisp/textmodes/tildify.el (tildify-foreach-region-outside-env): New function which calls a callback on portions of the buffer that are outside of ignored environments. (tildify-build-regexp): Remove function since it is now incorporated in `tildify-foreach-region-outside-env' where it is optimised and simplified by the use of `mapconcat'. (tildify-tildify): Return number of substitutions made so that… (tildify-count): …can be removed. (tildify-find-env): Accept a new PAIRS argument which was previously looked up in `tildify-ignored-environments-alist' each time the function was called. With this change, the lookup is performed only once in `tildify-foreach-region-outside-env'. (tildify-region): Greatly simplify the function since now most of the work is done by `tildify-foreach-region-outside-env'. (tildify-mode-alist): Simplify slightly by avoiding if and setq and instead using or. * tests/automated/tildify-tests.el (tildify-test-find-env-end-re-bug) (tildify-test-find-env-group-index-bug): Update to support new signature of the `tildify-foreach-region-outside-env' function. Namely, it now takes pairs as an argument instead of looking it up in `tildify-ignored-environments-alist'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:41:32 +0000 +++ lisp/ChangeLog 2014-06-05 14:42:07 +0000 @@ -1,5 +1,22 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-foreach-region-outside-env): New + function which calls a callback on portions of the buffer that are + outside of ignored environments. + (tildify-build-regexp): Remove function since it is now + incorporated in `tildify-foreach-region-outside-env' where it is + optimised and simplified by the use of `mapconcat'. + (tildify-tildify): Return number of substitutions made so that… + (tildify-count): …can be removed. + (tildify-find-env): Accept a new PAIRS argument which was + previously looked up in `tildify-ignored-environments-alist' each + time the function was called. With this change, the lookup is + performed only once in `tildify-foreach-region-outside-env'. + (tildify-region): Greatly simplify the function since now most of + the work is done by `tildify-foreach-region-outside-env'. + (tildify-mode-alist): Simplify slightly by avoiding if and setq + and instead using or. + * textmodes/tildify.el (tildify-ignored-environments-alist): Optimise environments regexes === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-06-05 14:41:32 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:42:07 +0000 @@ -3,7 +3,8 @@ ;; Copyright (C) 1997-2014 Free Software Foundation, Inc. ;; Author: Milan Zamazal -;; Version: 4.5.2 +;; Michal Nazarewicz +;; Version: 4.5.3 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -187,12 +188,6 @@ (symbol :tag "Like other"))))) -;;; *** Internal variables *** - -(defvar tildify-count nil - "Counter for replacements.") - - ;;; *** Interactive functions *** ;;;###autoload @@ -205,51 +200,16 @@ If DONT-ASK is set, or called interactively with prefix argument, user won't be prompted for confirmation of each substitution." (interactive "*rP") - (setq tildify-count 0) - (let (a - z - (marker-end (copy-marker end)) - end-env - finish - (ask (not dont-ask)) - (case-fold-search nil) - (regexp (tildify-build-regexp)) ; beginnings of environments - aux) - (if regexp - ;; Yes, ignored environments exist for the current major mode, - ;; tildify just texts outside them - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (not finish) - (setq a (point)) - (setq end-env (tildify-find-env regexp)) - (setq z (copy-marker (if end-env (1- (point)) (point-max)))) - (if (>= (marker-position z) beg) - (progn - (or (>= a beg) (setq a beg)) - (or (<= (marker-position z) (marker-position marker-end)) - (setq z marker-end)) - (setq aux (tildify-tildify a (marker-position z) ask)) - (if (eq aux 'force) - (setq ask nil) - (if (eq aux nil) - (setq finish t))))) - (if (>= (marker-position z) (marker-position marker-end)) - (setq finish t)) - (or (>= (point) (marker-position z)) - (goto-char (marker-position z))) - (if (not finish) - (if (re-search-forward end-env nil t) - (if (> (point) (marker-position marker-end)) - (setq finish t)) - (message - "End of environment not found: %s" end-env) - (setq finish t)))))) - ;; No ignored environments, tildify directly - (tildify-tildify beg end ask))) - (message "%d spaces replaced." tildify-count)) + (let (case-fold-search (count 0) (ask (not dont-ask))) + (tildify-foreach-region-outside-env beg end + (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)))) + (message "%d spaces replaced." count))) ;;;###autoload (defun tildify-buffer (&optional dont-ask) @@ -266,42 +226,58 @@ ;;; *** Auxiliary functions *** -(defun tildify-build-regexp () - "Build start of environment regexp." - (let ((alist (tildify-mode-alist tildify-ignored-environments-alist)) - regexp) - (when alist - (setq regexp (caar alist)) - (setq alist (cdr alist)) - (while alist - (setq regexp (concat regexp "\\|" (caar alist))) - (setq alist (cdr alist))) - regexp))) - (defun tildify-mode-alist (mode-alist &optional mode) "Return alist item for the MODE-ALIST in the current major MODE." - (if (null mode) - (setq mode major-mode)) - (let ((alist (cdr (or (assoc mode mode-alist) + (let ((alist (cdr (or (assoc (or mode major-mode) mode-alist) (assoc t mode-alist))))) (if (and alist (symbolp alist)) (tildify-mode-alist mode-alist alist) alist))) -(defun tildify-find-env (regexp) +(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)) + (let ((pairs (tildify-mode-alist 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) "Find environment using REGEXP. -Return regexp for the end of the environment or nil if no environment was -found." +Return regexp for the end of the environment found in PAIRS or nil if +no environment was found." ;; Find environment (when (re-search-forward regexp nil t) (save-match-data - ;; Build end-env regexp - (let ((match (match-string 0)) - (alist (tildify-mode-alist tildify-ignored-environments-alist))) - (while (not (eq (string-match (caar alist) match) 0)) - (setq alist (cdr alist))) - (let ((expression (cdar alist))) + (let ((match (match-string 0))) + (while (not (eq (string-match (caar pairs) match) 0)) + (setq pairs (cdr pairs))) + (let ((expression (cdar pairs))) (if (stringp expression) expression (mapconcat @@ -319,8 +295,9 @@ If ASK is nil, perform replace without asking user for confirmation. -Returns one of symbols: t (all right), nil (quit), force (replace without -further questions)." +Returns (count . response) cons where count is number of string +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-mode-alist tildify-pattern-alist)) @@ -332,7 +309,8 @@ bad-answer replace quit - (message-log-max nil)) + (message-log-max nil) + (count 0)) (while (and (not quit) (re-search-forward regexp (marker-position end-marker) t)) (when (or (not ask) @@ -359,12 +337,11 @@ (setq bad-answer t))) replace)) (replace-match tilde t t nil match-number) - (setq tildify-count (1+ tildify-count)))) + (setq count (1+ count)))) ;; Return value - (cond - (quit nil) - ((not ask) 'force) - (t t))))) + (cons count (cond (quit nil) + ((not ask) 'force) + (t t)))))) ;;; *** Announce *** === modified file 'test/ChangeLog' --- test/ChangeLog 2014-06-05 14:41:01 +0000 +++ test/ChangeLog 2014-06-05 14:42:07 +0000 @@ -1,5 +1,11 @@ 2014-06-05 Michal Nazarewicz + * automated/tildify-tests.el (tildify-test-find-env-end-re-bug) + (tildify-test-find-env-group-index-bug): Update to support new + signature of the `tildify-foreach-region-outside-env' function. + Namely, it now takes pairs as an argument instead of looking it up in + `tildify-ignored-environments-alist'. + * automated/tildify-tests.el (tildify-test--example-html): Add support for generating XML code, so that… (tildify-test-xml) …test can be added to check handling of XML === modified file 'test/automated/tildify-tests.el' --- test/automated/tildify-tests.el 2014-06-05 14:41:01 +0000 +++ test/automated/tildify-tests.el 2014-06-05 14:42:07 +0000 @@ -114,23 +114,22 @@ (ert-deftest tildify-test-find-env-end-re-bug () "Tests generation of end-regex using mix of indexes and strings" (with-temp-buffer - (let ((tildify-ignored-environments-alist - `((,major-mode ("foo\\|bar" . ("end-" 0)))))) - (insert "foo whatever end-foo") - (goto-char (point-min)) - (should (string-equal "end-foo" (tildify-find-env "foo\\|bar")))))) + (insert "foo whatever end-foo") + (goto-char (point-min)) + (should (string-equal "end-foo" + (tildify-find-env "foo\\|bar" + '(("foo\\|bar" . ("end-" 0)))))))) (ert-deftest tildify-test-find-env-group-index-bug () "Tests generation of match-string indexes" (with-temp-buffer - (let ((tildify-ignored-environments-alist - `((,major-mode ("start-\\(foo\\|bar\\)" . ("end-" 1)) - ("open-\\(foo\\|bar\\)" . ("close-" 1))))) + (let ((pairs '(("start-\\(foo\\|bar\\)" . ("end-" 1)) + ("open-\\(foo\\|bar\\)" . ("close-" 1)))) (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)))))) + (should (string-equal "close-foo" (tildify-find-env beg-re pairs)))))) (provide 'tildify-tests) ------------------------------------------------------------ revno: 117271 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:41:32 +0200 message: tildify.el: Optimise environments regexes * lisp/textmodes/tildify.el (tildify-ignored-environments-alist): Each time beginning of an environment to ignore is found, `tildify-find-env' needs to identify regexp for the ending of the environment. This is done by trying all the opening regexes on matched text in a loop, so to speed that up, this loop should have fewer things to match, which can be done by using alternatives in the opening regexes. Coincidentally, this should make matching of the opening regexp faster as well thanks to the use of `regexp-opt' and having common prefix pulled from many regexes. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:41:01 +0000 +++ lisp/ChangeLog 2014-06-05 14:41:32 +0000 @@ -1,5 +1,19 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-ignored-environments-alist): + Optimise environments regexes + + Each time beginning of an environment to ignore is found, + `tildify-find-env' needs to identify regexp for the ending + of the environment. This is done by trying all the opening + regexes on matched text in a loop, so to speed that up, this + loop should have fewer things to match, which can be done by + using alternatives in the opening regexes. + + Coincidentally, this should make matching of the opening + regexp faster as well thanks to the use of `regexp-opt' and + having common prefix pulled from many regexes. + * textmodes/tildify.el (tildify-string-alist) (tildify-ignored-environments-alist): Add `nxml-mode' to the list of supported modes since `xml-mode' is no longer a thing but just === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-06-05 14:41:01 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:41:32 +0000 @@ -119,42 +119,35 @@ (symbol :tag "Like other"))))) (defcustom tildify-ignored-environments-alist - '((latex-mode + `((latex-mode ("\\\\\\\\" . "") ; do not remove this - ("\\\\begin{verbatim}" . "\\\\end{verbatim}") + (,(eval-when-compile (concat + "\\\\begin{\\(" + (regexp-opt '("verbatim" "math" "displaymath" + "equation" "eqnarray" "eqnarray*")) + "\\)}")) + . ("\\\\end{" 1 "}")) ("\\\\verb\\*?\\(.\\)" . (1)) - ("\\$\\$" . "\\$\\$") - ("\\$" . "\\$") + ("\\$\\$?" . (0)) ("\\\\(" . "\\\\)") ("\\\\[[]" . "\\\\[]]") - ("\\\\begin{math}" . "\\\\end{math}") - ("\\\\begin{displaymath}" . "\\\\end{displaymath}") - ("\\\\begin{equation}" . "\\\\end{equation}") - ("\\\\begin{eqnarray\\*?}" . "\\\\end{eqnarray\\*?}") ("\\\\[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) - (t nil)) + (nxml-mode . xml-mode)) "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 ------------------------------------------------------------ revno: 117270 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:41:01 +0200 message: tildify.el: Better support for XML * lisp/textmodes/tildify.el (tildify-string-alist) (tildify-ignored-environments-alist): Add `nxml-mode' to the list of supported modes since `xml-mode' is no longer a thing but just an alias to the former. Also include comments and insides of tags in `tildify-ignored-environments-alist' for XML modes. Finally, since XML does not define “ ”[1], use a numeric reference for a no-break space (namely “ ”) [1] XML specification defines only a handful of predefined entities. The list is at and includes only <, >, &, ' and " (meaning <, >, &, ' and " respectively). This is in contrast to HTML and even XHTML which defined a whole bunch of entities including “ ”. * automated/tildify-tests.el (tildify-test--example-html): Add support for generating XML code, so that… (tildify-test-xml) …test can be added to check handling of XML documents. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:40:26 +0000 +++ lisp/ChangeLog 2014-06-05 14:41:01 +0000 @@ -1,5 +1,19 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-string-alist) + (tildify-ignored-environments-alist): Add `nxml-mode' to the list + of supported modes since `xml-mode' is no longer a thing but just + an alias to the former. Also include comments and insides of tags + in `tildify-ignored-environments-alist' for XML modes. Finally, + since XML does not define “ ”[1], use a numeric reference for + a no-break space (namely “ ”) + + [1] XML specification defines only a handful of predefined entities. + The list is at + and includes only <, >, &, ' and " (meaning <, + >, &, ' and " respectively). This is in contrast to HTML and even + XHTML which defined a whole bunch of entities including “ ”. + * textmodes/tildify.el (tildify-pattern-alist) (tildify-string-alist, tildify-ignored-environments-alist): Improve defcustom's types by adding more tags explaining what each === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-06-05 14:40:26 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:41:01 +0000 @@ -90,8 +90,9 @@ (tex-mode . latex-mode) (plain-tex-mode . latex-mode) (sgml-mode . " ") - (xml-mode . sgml-mode) (html-mode . sgml-mode) + (xml-mode . " ") ; XML does not define   use numeric reference + (nxml-mode . xml-mode) (t . " ")) "Alist specifying what is a hard space in the current major mode. @@ -149,6 +150,10 @@ ("") ("<" . ">")) (sgml-mode . html-mode) + (xml-mode + ("") + ("<" . ">")) + (nxml-mode . xml-mode) (t nil)) "Alist specifying ignored structured text environments. Parts of text defined in this alist are skipped without performing hard space === modified file 'test/ChangeLog' --- test/ChangeLog 2014-06-05 14:39:18 +0000 +++ test/ChangeLog 2014-06-05 14:41:01 +0000 @@ -1,5 +1,10 @@ 2014-06-05 Michal Nazarewicz + * automated/tildify-tests.el (tildify-test--example-html): Add support + for generating XML code, so that… + (tildify-test-xml) …test can be added to check handling of XML + documents. + * automated/tildify-tests.el (tildify-test-find-env-group-index-bug): New test checking end-regex building when multiple environment pairs use integers to refer to capture groups. === modified file 'test/automated/tildify-tests.el' --- test/automated/tildify-tests.el 2014-06-05 14:39:18 +0000 +++ test/automated/tildify-tests.el 2014-06-05 14:41:01 +0000 @@ -36,14 +36,15 @@ "consectetur adipiscing elit.")) -(defun tildify-test--example-html (sentence &optional with-nbsp) +(defun tildify-test--example-html (sentence &optional with-nbsp is-xml) "Return an example HTML code. SENTENCE is placed where spaces should not be replaced with hard spaces, and WITH-NBSP is placed where spaces should be replaced with hard spaces. If the -latter is missing, SENTENCE will be used in all placeholder positions." +latter is missing, SENTENCE will be used in all placeholder positions. +If IS-XML is non-nil,
 tag is not treated specially."
   (let ((with-nbsp (or with-nbsp sentence)))
     (concat "

" with-nbsp "

\n" - "
" sentence "
\n" + "
" (if is-xml with-nbsp sentence) "
\n" "\n" "

" with-nbsp "

\n" "<" sentence ">\n"))) @@ -77,6 +78,14 @@ (tildify-test--example-html sentence sentence) (tildify-test--example-html sentence with-nbsp)))) +(ert-deftest tildify-test-xml () + "Tests tildification in an XML document" + (let* ((sentence (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)))) + (defun tildify-test--example-tex (sentence &optional with-nbsp) "Return an example (La)Tex code. ------------------------------------------------------------ revno: 117269 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:40:26 +0200 message: tildify.el: Improve defcustom's types * lisp/textmodes/tildify.el (tildify-pattern-alist) (tildify-string-alist, tildify-ignored-environments-alist): Add more tags explaining what each value means and replace “sexp” used in `tildify-ignored-environments-alist' with a full type declaration. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:39:18 +0000 +++ lisp/ChangeLog 2014-06-05 14:40:26 +0000 @@ -1,5 +1,11 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-pattern-alist) + (tildify-string-alist, tildify-ignored-environments-alist): + Improve defcustom's types by adding more tags explaining what each + value means and replace “sexp” used in + `tildify-ignored-environments-alist' with a full type declaration. + * textmodes/tildify.el (tildify-find-env): Fix matched group indexes in end-regex building === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-06-05 14:39:18 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:40:26 +0000 @@ -77,7 +77,13 @@ 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." :group 'tildify - :type '(repeat (choice (list symbol regexp integer) (cons symbol symbol)))) + :type '(repeat (cons :tag "Entry for major mode" + (choice (const :tag "Default" t) + (symbol :tag "Major mode")) + (choice (list :tag "Regexp" + regexp + (integer :tag "Group ")) + (symbol :tag "Like other"))))) (defcustom tildify-string-alist '((latex-mode . "~") @@ -104,7 +110,12 @@ 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." :group 'tildify - :type '(repeat (cons symbol (choice string symbol)))) + :type '(repeat (cons :tag "Entry for major mode" + (choice (const :tag "Default" t) + (symbol :tag "Major mode")) + (choice (const :tag "No-break space (U+00A0)" "\u00A0") + (string :tag "String ") + (symbol :tag "Like other"))))) (defcustom tildify-ignored-environments-alist '((latex-mode @@ -160,7 +171,22 @@ subexpressions of BEG-REGEX (this is used to solve cases like \\\\verb in TeX)." :group 'tildify - :type '(repeat (cons symbol (choice symbol (repeat sexp))))) + :type '(repeat + (cons :tag "Entry for major mode" + (choice (const :tag "Default" t) + (symbol :tag "Major mode")) + (choice + (const :tag "None") + (repeat + :tag "Environments" + (cons :tag "Regexp pair" + (regexp :tag "Open ") + (choice :tag "Close" + (regexp :tag "Regexp") + (list :tag "Regexp and groups (concatenated)" + (choice (regexp :tag "Regexp") + (integer :tag "Group ")))))) + (symbol :tag "Like other"))))) ;;; *** Internal variables *** ------------------------------------------------------------ revno: 117268 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:39:18 +0200 message: tildify.el: Fix matched group indexes in end-regex building * lisp/textmodes/tildifi.el (tildify-find-env): When looking for a start of an ignore-environment, the regex is built by concatenating regexes of all the environments configured in `tildify-ignored-environments-alist'. So for example, the following list could be used to match TeX's \verb and \verb* commands: (("\\\\verb\\(.\\)" . (1)) ("\\\\verb\\*\\(.\\)" . (1))) This would result in the following regex being used to find the start of any of the variants of the \verb command: \\\\verb\\(.\\)\\|\\\\verb\\*\\(.\\) But now, if “\\\\verb\\*\\(.\\)” matches, the first capture group won't match anything, and thus (match-string 1) will be nil, which will cause building of the end-matching regex to fail. Fix this by using capture groups from the time when the opening regexes are matched individually. * tests/automated/tildify-tests.el (tildify-test-find-env-group-index-bug): New test validating fix to the above bug. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 14:37:45 +0000 +++ lisp/ChangeLog 2014-06-05 14:39:18 +0000 @@ -1,5 +1,28 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-find-env): Fix matched group + indexes in end-regex building + + When looking for a start of an ignore-environment, the regex is built + by concatenating regexes of all the environments configured in + `tildify-ignored-environments-alist'. So for example, the following + list could be used to match TeX's \verb and \verb* commands: + + (("\\\\verb\\(.\\)" . (1)) + ("\\\\verb\\*\\(.\\)" . (1))) + + This would result in the following regex being used to find the start + of any of the variants of the \verb command: + + \\\\verb\\(.\\)\\|\\\\verb\\*\\(.\\) + + But now, if “\\\\verb\\*\\(.\\)” matches, the first capture group + won't match anything, and thus (match-string 1) will be nil, which + will cause building of the end-matching regex to fail. + + Fix this by using capture groups from the time when the opening + regexes are matched individually. + * textmodes/tildify.el (tildify-find-env): Fix end-regex building in `tildify-find-env' === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-06-05 14:37:45 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:39:18 +0000 @@ -271,22 +271,22 @@ found." ;; Find environment (when (re-search-forward regexp nil t) - ;; Build end-env regexp - (let ((match (match-string 0)) - (alist (tildify-mode-alist tildify-ignored-environments-alist))) - (save-match-data + (save-match-data + ;; Build end-env regexp + (let ((match (match-string 0)) + (alist (tildify-mode-alist tildify-ignored-environments-alist))) (while (not (eq (string-match (caar alist) match) 0)) - (setq alist (cdr alist)))) - (let ((expression (cdar alist))) - (if (stringp expression) - expression - (mapconcat - (lambda (expr) - (if (stringp expr) - expr - (regexp-quote (match-string expr)))) - expression - "")))))) + (setq alist (cdr alist))) + (let ((expression (cdar alist))) + (if (stringp expression) + expression + (mapconcat + (lambda (expr) + (if (stringp expr) + expr + (regexp-quote (match-string expr match)))) + expression + ""))))))) (defun tildify-tildify (beg end ask) "Add tilde characters in the region between BEG and END. === modified file 'test/ChangeLog' --- test/ChangeLog 2014-06-05 14:37:45 +0000 +++ test/ChangeLog 2014-06-05 14:39:18 +0000 @@ -1,5 +1,9 @@ 2014-06-05 Michal Nazarewicz + * automated/tildify-tests.el (tildify-test-find-env-group-index-bug): + New test checking end-regex building when multiple environment pairs + use integers to refer to capture groups. + * automated/tildify-tests.el (tildify-test-find-env-end-re-bug): New test checking end-regex building in `tildify-find-env' function when integers (denoting capture groups) and strings are mixed together. === modified file 'test/automated/tildify-tests.el' --- test/automated/tildify-tests.el 2014-06-05 14:37:45 +0000 +++ test/automated/tildify-tests.el 2014-06-05 14:39:18 +0000 @@ -112,6 +112,18 @@ (should (string-equal "end-foo" (tildify-find-env "foo\\|bar")))))) +(ert-deftest tildify-test-find-env-group-index-bug () + "Tests generation of match-string indexes" + (with-temp-buffer + (let ((tildify-ignored-environments-alist + `((,major-mode ("start-\\(foo\\|bar\\)" . ("end-" 1)) + ("open-\\(foo\\|bar\\)" . ("close-" 1))))) + (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)))))) + + (provide 'tildify-tests) ;;; tildify-tests.el ends here ------------------------------------------------------------ revno: 117267 committer: Michal Nazarewicz branch nick: emacs-trunk timestamp: Thu 2014-06-05 16:37:45 +0200 message: tildify.el: Fix end-regex building in `tildify-find-env' * lisp/textmodes/tildify.el (tildify-find-env): The `tildify-ignored-environments-alist' allows the end-regex to be provided not as a static string but mix of strings and indexes of groups matched the begin-regex. For example, the “\verb!…!” TeX-command (where “!” is an arbitrary character) is handled using: ("\\\\verb\\*?\\(.\\)" . (1)) In the same way, the following should be supported as well: ("open-\\(.\\)" . ("end-" 1)) However the tildify-find-env function fails at (concat result (if (stringp (setq aux (car expression))) expression ; BUG: expression is a list (regexp-quote (match-string aux)))) where the string part is handled incorrectly. The most trivial fix would be to replace `expression' in the true-part of the if-statement with `aux', but instead, this commit optimises `tildify-find-env' by changing it to use `mapconcat' rather than open-coded while-loop. * tests/automated/tildify-tests.el (tildify-test-find-env-end-re-bug): New test validating fix to the above bug. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-05 13:40:54 +0000 +++ lisp/ChangeLog 2014-06-05 14:37:45 +0000 @@ -1,3 +1,34 @@ +2014-06-05 Michal Nazarewicz + + * textmodes/tildify.el (tildify-find-env): Fix end-regex building + in `tildify-find-env' + + The `tildify-ignored-environments-alist' allows the end-regex to + be provided not as a static string but mix of strings and indexes + of groups matched the begin-regex. For example, the “\verb!…!” + TeX-command (where “!” is an arbitrary character) is handled + using: + + ("\\\\verb\\*?\\(.\\)" . (1)) + + In the same way, the following should be supported as well: + + ("open-\\(.\\)" . ("end-" 1)) + + However the tildify-find-env function fails at + + (concat result + (if (stringp (setq aux (car expression))) + expression ; BUG: expression is a list + (regexp-quote (match-string aux)))) + + where the string part is handled incorrectly. + + The most trivial fix would be to replace `expression' in the + true-part of the if-statement with `aux', but instead, this commit + optimises `tildify-find-env' by changing it to use `mapconcat' + rather than open-coded while-loop. + 2014-06-05 Mario Lang * woman.el (woman-mapcan): Remove. === modified file 'lisp/textmodes/tildify.el' --- lisp/textmodes/tildify.el 2014-05-28 01:00:44 +0000 +++ lisp/textmodes/tildify.el 2014-06-05 14:37:45 +0000 @@ -3,7 +3,7 @@ ;; Copyright (C) 1997-2014 Free Software Foundation, Inc. ;; Author: Milan Zamazal -;; Version: 4.5.1 +;; Version: 4.5.2 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -270,27 +270,23 @@ Return regexp for the end of the environment or nil if no environment was found." ;; Find environment - (if (re-search-forward regexp nil t) - ;; Build end-env regexp - (let ((match (match-string 0)) - (alist (tildify-mode-alist tildify-ignored-environments-alist)) - expression) - (save-match-data - (while (not (eq (string-match (caar alist) match) 0)) - (setq alist (cdr alist)))) - (if (stringp (setq expression (cdar alist))) - expression - (let ((result "") - aux) - (while expression - (setq result (concat result - (if (stringp (setq aux (car expression))) - expression - (regexp-quote (match-string aux))))) - (setq expression (cdr expression))) - result))) - ;; Return nil if not found - nil)) + (when (re-search-forward regexp nil t) + ;; Build end-env regexp + (let ((match (match-string 0)) + (alist (tildify-mode-alist tildify-ignored-environments-alist))) + (save-match-data + (while (not (eq (string-match (caar alist) match) 0)) + (setq alist (cdr alist)))) + (let ((expression (cdar alist))) + (if (stringp expression) + expression + (mapconcat + (lambda (expr) + (if (stringp expr) + expr + (regexp-quote (match-string expr)))) + expression + "")))))) (defun tildify-tildify (beg end ask) "Add tilde characters in the region between BEG and END. === modified file 'test/ChangeLog' --- test/ChangeLog 2014-06-02 18:38:22 +0000 +++ test/ChangeLog 2014-06-05 14:37:45 +0000 @@ -1,3 +1,9 @@ +2014-06-05 Michal Nazarewicz + + * automated/tildify-tests.el (tildify-test-find-env-end-re-bug): New + test checking end-regex building in `tildify-find-env' function when + integers (denoting capture groups) and strings are mixed together. + 2014-06-02 Michael Albinus * automated/tramp-tests.el (tramp-remote-process-environment): Declare. === modified file 'test/automated/tildify-tests.el' --- test/automated/tildify-tests.el 2014-05-28 01:00:44 +0000 +++ test/automated/tildify-tests.el 2014-06-05 14:37:45 +0000 @@ -101,6 +101,17 @@ (tildify-test--example-tex sentence sentence) (tildify-test--example-tex sentence with-nbsp)))) + +(ert-deftest tildify-test-find-env-end-re-bug () + "Tests generation of end-regex using mix of indexes and strings" + (with-temp-buffer + (let ((tildify-ignored-environments-alist + `((,major-mode ("foo\\|bar" . ("end-" 0)))))) + (insert "foo whatever end-foo") + (goto-char (point-min)) + (should (string-equal "end-foo" (tildify-find-env "foo\\|bar")))))) + + (provide 'tildify-tests) ;;; tildify-tests.el ends here ------------------------------------------------------------ revno: 117266 committer: Mario Lang branch nick: trunk timestamp: Thu 2014-06-05 15:40:54 +0200 message: * woman.el (woman-mapcan): Remove. (woman-parse-colon-path): Use cl-mapcan instead. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-06-03 09:06:18 +0000 +++ lisp/ChangeLog 2014-06-05 13:40:54 +0000 @@ -1,3 +1,8 @@ +2014-06-05 Mario Lang + + * woman.el (woman-mapcan): Remove. + (woman-parse-colon-path): Use cl-mapcan instead. + 2014-06-03 Rüdiger Sonderfeld * register.el: Add link to Emacs manual in Commentary. === modified file 'lisp/woman.el' --- lisp/woman.el 2014-02-10 01:34:22 +0000 +++ lisp/woman.el 2014-06-05 13:40:54 +0000 @@ -414,18 +414,12 @@ (substring arg 0 (match-end 1)) arg)))) +(require 'cl-lib) + (eval-when-compile ; to avoid compiler warnings (require 'dired) - (require 'cl-lib) (require 'apropos)) -(defun woman-mapcan (fn x) - "Return concatenated list of FN applied to successive `car' elements of X. -FN must return a list, cons or nil. Useful for splicing into a list." - ;; Based on the Standard Lisp function MAPCAN but with args swapped! - ;; More concise implementation than the recursive one. -- dak - (apply #'nconc (mapcar fn x))) - (defun woman-parse-colon-path (paths) "Explode search path string PATHS into a list of directory names. Allow Cygwin colon-separated search paths on Microsoft platforms. @@ -440,7 +434,7 @@ (mapcar 'woman-Cyg-to-Win (woman-parse-man.conf))) ((string-match-p ";" paths) ;; Assume DOS-style path-list... - (woman-mapcan ; splice list into list + (cl-mapcan ; splice list into list (lambda (x) (if x (list x) @@ -451,14 +445,14 @@ (list paths)) (t ;; Assume UNIX/Cygwin-style path-list... - (woman-mapcan ; splice list into list + (cl-mapcan ; splice list into list (lambda (x) (mapcar 'woman-Cyg-to-Win (if x (list x) (woman-parse-man.conf)))) (let ((path-separator ":")) (parse-colon-path paths))))) ;; Assume host-default-style path-list... - (woman-mapcan ; splice list into list + (cl-mapcan ; splice list into list (lambda (x) (if x (list x) (woman-parse-man.conf))) (parse-colon-path (or paths ""))))) ------------------------------------------------------------ revno: 117265 committer: Paul Eggert branch nick: trunk timestamp: Thu 2014-06-05 01:03:22 -0700 message: Try harder to find GNU Make when configuring. * configure.ac (AC_PROG_MAKE_SET): Define a dummy. (MAKE): Set it to GNU Make, if one can be found. Search PATH for 'make', 'gmake', 'gnumake'. This works better on platforms like AIX, where GNU Make might be in /opt/freeware/bin/make, and reside behind /usr/bin/make in the PATH. diff: === modified file 'ChangeLog' --- ChangeLog 2014-06-05 06:24:54 +0000 +++ ChangeLog 2014-06-05 08:03:22 +0000 @@ -1,3 +1,13 @@ +2014-06-05 Paul Eggert + + Try harder to find GNU Make when configuring. + * configure.ac (AC_PROG_MAKE_SET): Define a dummy. + (MAKE): Set it to GNU Make, if one can be found. + Search PATH for 'make', 'gmake', 'gnumake'. + This works better on platforms like AIX, where GNU Make + might be in /opt/freeware/bin/make, and reside + behind /usr/bin/make in the PATH. + 2014-06-05 Dmitry Antipov * configure.ac (POLL_FOR_INPUT): Define with HAVE_WINDOW_SYSTEM. === modified file 'configure.ac' --- configure.ac 2014-06-05 06:24:54 +0000 +++ configure.ac 2014-06-05 08:03:22 +0000 @@ -92,7 +92,7 @@ if test -n "$XCRUN"; then if test -z "$MAKE"; then dnl Call the variable MAKE_PROG, not MAKE, to avoid confusion with - dnl SET_MAKE and with the usual MAKE variable that 'make' itself uses. + dnl the usual MAKE variable that 'make' itself uses. AC_CHECK_PROG([MAKE_PROG], [make], [yes]) if test -z "$MAKE_PROG"; then MAKE="$XCRUN MAKE" @@ -102,6 +102,47 @@ fi fi +dnl GNU Make is required, so don't test for its individual features. +am_cv_make_support_nested_variables=yes +AC_DEFUN([AC_PROG_MAKE_SET], + [SET_MAKE= + AC_SUBST([SET_MAKE])]) + +dnl Check for GNU Make and possibly set MAKE before running AM_INIT_AUTOMAKE. +AC_CACHE_CHECK([for GNU Make], [ac_cv_path_MAKE], + [ac_path_MAKE_found=false + if test -n "$MAKE"; then + emacs_makeout=`($MAKE --version) 2>/dev/null` && + case $emacs_makeout in + 'GNU Make '*) + ac_path_MAKE_found=:;; + esac + ac_cv_path_MAKE=$MAKE + else + emacs_tried_make=false + emacs_tried_gmake=false + emacs_tried_gnumake=false + AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake gnumake], + [[emacs_makeout=`($ac_path_MAKE --version) 2>/dev/null` && + case $emacs_makeout in + 'GNU Make '*) + # Use the fully-qualified program name only if the basename + # would not resolve to it. + if eval \$emacs_tried_$ac_prog; then + ac_cv_path_MAKE=$ac_path_MAKE + else + ac_cv_path_MAKE=$ac_prog + fi + ac_path_MAKE_found=:;; + esac + eval emacs_tried_$ac_prog=:]]) + fi]) +$ac_path_MAKE_found || { AC_MSG_ERROR([[Building Emacs requires GNU Make. +If you have it installed under another name, configure with 'MAKE=...'. +For example, run '$0 MAKE=gnu-make'.]]) +} +MAKE=$ac_cv_path_MAKE + dnl Fairly arbitrary, older versions might work too. AM_INIT_AUTOMAKE(1.11) @@ -659,18 +700,6 @@ fi -AC_MSG_CHECKING([whether we are using GNU Make]) -testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'` -if test "x$testval" != x; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) - AC_MSG_ERROR([Building Emacs requires GNU make. -If you have it installed under another name, configure with 'MAKE=...'. -For example, run './configure MAKE=gmake'.]) -fi - - #### Choose a compiler. dnl Don't bother to test for C89. @@ -1531,7 +1560,6 @@ dnl AC_C_BIGENDIAN is done by gnulib. dnl check for Make feature -dnl AC_PROG_MAKE_SET is done by Automake. DEPFLAGS= MKDEPDIR=":" @@ -5090,3 +5118,5 @@ ]) AC_OUTPUT + +test "$MAKE" = make || AC_MSG_NOTICE([Now you can run '$MAKE'.])