commit b0e6ecfc33077fb2dce904d315c8ef24e3649c9b (HEAD, refs/remotes/origin/master) Author: Dmitry Gutov Date: Sat Dec 29 20:06:24 2018 +0300 Skip 'basic' completion style for project-find-file * lisp/minibuffer.el (completion-category-defaults): Skip 'basic' for 'project-file', in order not to prefer files at the top of the directory tree. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f8e328f615..bc7d26ac2e 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -835,7 +835,7 @@ styles for specific categories, such as files, buffers, etc." (defvar completion-category-defaults '((buffer (styles . (basic substring))) (unicode-name (styles . (basic substring))) - (project-file (styles . (basic substring))) + (project-file (styles . (substring))) (info-menu (styles . (basic substring)))) "Default settings for specific completion categories. Each entry has the shape (CATEGORY . ALIST) where ALIST is commit b71d4ce056ca291594682b2a8536a4a768a97330 Author: Mattias Engdegård Date: Sat Dec 29 11:09:27 2018 +0100 Handle raw bytes, and LF in ranges, in rx `any' argument strings * lisp/emacs-lisp/rx.el (rx-check-any-string): Rewrite to handle raw bytes in unibyte strings and accept LF as range endpoints (Bug#33205). * test/lisp/emacs-lisp/rx-tests.el: Add tests for the above. diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 1230df4f15..1cae22f870 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -449,28 +449,35 @@ Only both edges of each range is checked." (defun rx-check-any-string (str) - "Check string argument STR for Rx `any'." - (let ((i 0) - c1 c2 l) - (if (= 0 (length str)) - (error "String arg for Rx `any' must not be empty")) - (while (string-match ".-." str i) - ;; string before range: convert it to characters - (if (< i (match-beginning 0)) - (setq l (nconc - l - (append (substring str i (match-beginning 0)) nil)))) - ;; range - (setq i (match-end 0) - c1 (aref str (match-beginning 0)) - c2 (aref str (1- i))) - (cond - ((< c1 c2) (setq l (nconc l (list (cons c1 c2))))) - ((= c1 c2) (setq l (nconc l (list c1)))))) - ;; rest? - (if (< i (length str)) - (setq l (nconc l (append (substring str i) nil)))) - l)) + "Turn the `any' argument string STR into a list of characters. +The original order is not preserved. Ranges, \"A-Z\", become pairs, (?A . ?Z)." + (let ((decode-char + ;; Make sure raw bytes are decoded as such, to avoid confusion with + ;; U+0080..U+00FF. + (if (multibyte-string-p str) + #'identity + (lambda (c) (if (<= #x80 c #xff) + (+ c #x3fff00) + c)))) + (len (length str)) + (i 0) + (ret nil)) + (if (= 0 len) + (error "String arg for Rx `any' must not be empty")) + (while (< i len) + (cond ((and (< i (- len 2)) + (= (aref str (+ i 1)) ?-)) + ;; Range. + (let ((start (funcall decode-char (aref str i))) + (end (funcall decode-char (aref str (+ i 2))))) + (cond ((< start end) (push (cons start end) ret)) + ((= start end) (push start ret))) + (setq i (+ i 3)))) + (t + ;; Single character. + (push (funcall decode-char (aref str i)) ret) + (setq i (+ i 1))))) + ret)) (defun rx-check-any (arg) diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index d15e3d7719..8b3ce6cb01 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -33,6 +33,28 @@ (number-sequence ?< ?\]) (number-sequence ?- ?:)))))) +(ert-deftest rx-char-any-range-nl () + "Test character alternatives with LF as a range endpoint." + (should (equal (rx (any "\n-\r")) + "[\n-\r]")) + (should (equal (rx (any "\a-\n")) + "[\a-\n]"))) + +(ert-deftest rx-char-any-raw-byte () + "Test raw bytes in character alternatives." + ;; Separate raw characters. + (should (equal (string-match-p (rx (any "\326A\333B")) + "X\326\333") + 1)) + ;; Range of raw characters, unibyte. + (should (equal (string-match-p (rx (any "\200-\377")) + "ÿA\310B") + 2)) + ;; Range of raw characters, multibyte. + (should (equal (string-match-p (rx (any "Å\211\326-\377\177")) + "XY\355\177\327") + 2))) + (ert-deftest rx-pcase () (should (equal (pcase "a 1 2 3 1 1 b" ((rx (let u (+ digit)) space commit fb10834a602416f8422131d5ce9dabcc28e57be4 Author: Martin Rudalics Date: Sat Dec 29 10:51:35 2018 +0100 Avoid that unwind_format_mode_line messes up buffer points (Bug#32777) * src/xdisp.c (format_mode_line_unwind_data): Before temporarily selecting a window on another frame, separately save the point of that window's buffer too. (unwind_format_mode_line): After undoing the temporary selection of a window on another frame, separately restore the buffer point of that window. This is needed since the operation that deselects that window will have stored back the point of that window into its buffer's point which is wrong since that window was never "officially" selected (Bug#32777). diff --git a/src/xdisp.c b/src/xdisp.c index 4201bdc4a7..65a61a0120 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11850,7 +11850,7 @@ format_mode_line_unwind_data (struct frame *target_frame, Vmode_line_unwind_vector = Qnil; if (NILP (vector)) - vector = make_nil_vector (10); + vector = make_nil_vector (12); ASET (vector, 0, make_fixnum (mode_line_target)); ASET (vector, 1, make_fixnum (MODE_LINE_NOPROP_LEN (0))); @@ -11867,12 +11867,24 @@ format_mode_line_unwind_data (struct frame *target_frame, ASET (vector, 7, owin); if (target_frame) { + Lisp_Object buffer = XWINDOW (target_frame->selected_window)->contents; + struct buffer *b = XBUFFER (buffer); + struct buffer *cb = current_buffer; + /* Similarly to `with-selected-window', if the operation selects a window on another frame, we must restore that frame's selected window, and (for a tty) the top-frame. */ ASET (vector, 8, target_frame->selected_window); if (FRAME_TERMCAP_P (target_frame)) ASET (vector, 9, FRAME_TTY (target_frame)->top_frame); + + /* If we select a window on another frame, make sure that that + selection does not leave its buffer's point modified when + unwinding (Bug#32777). */ + ASET (vector, 10, buffer); + current_buffer = b; + ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE)); + current_buffer = cb; } return vector; @@ -11912,6 +11924,24 @@ unwind_format_mode_line (Lisp_Object vector) } Fselect_window (old_window, Qt); + + /* Restore point of target_frame_window's buffer (Bug#32777). + But do this only after old_window has been reselected to + avoid that the window point of target_frame_window moves. */ + if (!NILP (target_frame_window)) + { + Lisp_Object buffer = AREF (vector, 10); + + if (BUFFER_LIVE_P (XBUFFER (buffer))) + { + struct buffer *cb = current_buffer; + + current_buffer = XBUFFER (buffer); + set_point_from_marker (AREF (vector, 11)); + ASET (vector, 11, Qnil); + current_buffer = cb; + } + } } if (!NILP (AREF (vector, 6)))