commit 1b8f013d179e8866819fe53b4708b57e753a08fc (HEAD, refs/remotes/origin/master) Author: Tassilo Horn Date: Sun May 16 09:21:48 2021 +0200 Bug reference auto-setup for Rmail * lisp/progmodes/bug-reference.el (bug-reference-try-setup-from-rmail): New function setting up `bug-reference-mode' from the current Rmail message. diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 81aeb60bdd..bdbe048a93 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -238,8 +238,8 @@ and apply it if applicable." "An alist for setting up `bug-reference-mode' in mail modes. This takes action if `bug-reference-mode' is enabled in group and -message buffers of Emacs mail clients. Currently, only Gnus is -supported. +message buffers of Emacs mail clients. Currently, Gnus and Rmail +are supported. Each element has the form @@ -342,6 +342,24 @@ and set it if applicable." (push val header-values)))))) (bug-reference--maybe-setup-from-mail nil header-values))))))) +(defun bug-reference-try-setup-from-rmail () + "Try setting up `bug-reference-mode' from the current rmail mail. +Looks at the headers List-Id, To, From, and Cc and tries to guess +suitable values for `bug-reference-bug-regexp' and +`bug-reference-url-format'." + (with-demoted-errors + "Error in bug-reference-try-setup-from-rmail: %S" + (when (and bug-reference-mode + (derived-mode-p 'rmail-mode)) + (let (header-values) + (save-excursion + (goto-char (point-min)) + (dolist (field '("list-id" "to" "from" "cc")) + (let ((val (mail-fetch-field field))) + (when val + (push val header-values))))) + (bug-reference--maybe-setup-from-mail nil header-values))))) + (defvar bug-reference-setup-from-irc-alist `((,(concat "#" (regexp-opt '("emacs" "gnus" "org-mode" "rcirc" "erc") 'words)) @@ -423,6 +441,7 @@ and set it if applicable." (defvar bug-reference-auto-setup-functions (list #'bug-reference-try-setup-from-vc #'bug-reference-try-setup-from-gnus + #'bug-reference-try-setup-from-rmail #'bug-reference-try-setup-from-rcirc #'bug-reference-try-setup-from-erc) "Functions trying to auto-setup `bug-reference-mode'. commit b6e0b66e0edfcf339b37cd4ddc99a56dee1df213 Author: Dmitry Gutov Date: Sat May 15 23:46:30 2021 +0300 Update CSS completion tests * test/lisp/textmodes/css-mode-tests.el (css-test-complete-pseudo-class) (css-test-complete-pseudo-element): Update the tests for recent changes. diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 97f5abf115..abf85dbff4 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -143,20 +143,20 @@ (css-mode) (insert "body:a") (let ((completions (css-mode-tests--completions))) - (should (member "active" completions)) - (should-not (member "disabled" completions)) + (should (member ":active" completions)) + (should-not (member ":disabled" completions)) ;; Don't include pseudo-elements - (should-not (member "after" completions))))) + (should-not (member "::after" completions))))) (ert-deftest css-test-complete-pseudo-element () (with-temp-buffer (css-mode) (insert "body::a") (let ((completions (css-mode-tests--completions))) - (should (member "after" completions)) - (should-not (member "disabled" completions)) + (should (member "::after" completions)) + (should-not (member "::disabled" completions)) ;; Don't include pseudo-classes - (should-not (member "active" completions))))) + (should-not (member ":active" completions))))) (ert-deftest css-test-complete-at-rule () (with-temp-buffer commit de61b0b25f0ff47e6da1c86da04b37bc61f963df Author: Tassilo Horn Date: Sat May 15 21:19:55 2021 +0200 Refactor bug-reference setup functions into a defvar * lisp/progmodes/bug-reference.el (bug-reference-auto-setup-functions): New defvar so that other packages can add their own auto-setup functions to it. * lisp/progmodes/bug-reference.el (bug-reference--run-auto-setup): Use the new variable instead of hard-coding the 4 functions we've had already. diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 0c5837cae7..81aeb60bdd 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -420,6 +420,24 @@ and set it if applicable." (erc-format-target) (erc-network-name)))) +(defvar bug-reference-auto-setup-functions + (list #'bug-reference-try-setup-from-vc + #'bug-reference-try-setup-from-gnus + #'bug-reference-try-setup-from-rcirc + #'bug-reference-try-setup-from-erc) + "Functions trying to auto-setup `bug-reference-mode'. +These functions are run after `bug-reference-mode' has been +activated in a buffer and try to guess suitable values for +`bug-reference-bug-regexp' and `bug-reference-url-format'. Their +guesswork is based on these variables: + +- `bug-reference-setup-from-vc-alist' for guessing based on + version control, e.g., URL of repository. +- `bug-reference-setup-from-mail-alist' for guessing based on + mail group names or mail header values. +- `bug-reference-setup-from-irc-alist' for guessing based on IRC + channel or network names.") + (defun bug-reference--run-auto-setup () (when (or bug-reference-mode bug-reference-prog-mode) @@ -430,10 +448,7 @@ and set it if applicable." (with-demoted-errors "Error during bug-reference auto-setup: %S" (catch 'setup - (dolist (f (list #'bug-reference-try-setup-from-vc - #'bug-reference-try-setup-from-gnus - #'bug-reference-try-setup-from-rcirc - #'bug-reference-try-setup-from-erc)) + (dolist (f bug-reference-auto-setup-functions) (when (funcall f) (throw 'setup t)))))))) commit b5e6dba05fcb4fa1c716dc759f8c4b2561bacaa7 Author: Eli Zaretskii Date: Sat May 15 20:44:40 2021 +0300 Fix segfaults when byte-compiling with native-compilation * src/emacs.c (main): Call 'set_initial_minibuffer_mode' before entering recursive-exit. * src/minibuf.c (init_minibuf_once_for_pdumper): Don't call 'set_minibuffer_mode' here... (set_initial_minibuffer_mode): ... set it in this new function. (Bug#48446) * src/lisp.h: Add prototype for 'set_initial_minibuffer_mode'. diff --git a/src/emacs.c b/src/emacs.c index 9157cd84a9..60a57a693c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2294,6 +2294,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem Vdump_mode = build_string (dump_mode); /* Enter editor command loop. This never returns. */ + set_initial_minibuffer_mode (); Frecursive_edit (); eassume (false); } diff --git a/src/lisp.h b/src/lisp.h index f83c55f827..91b7a89d0f 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4377,6 +4377,7 @@ extern EMACS_INT this_minibuffer_depth (Lisp_Object); extern EMACS_INT minibuf_level; extern Lisp_Object get_minibuffer (EMACS_INT); extern void init_minibuf_once (void); +extern void set_initial_minibuffer_mode (void); extern void syms_of_minibuf (void); extern void barf_if_interaction_inhibited (void); diff --git a/src/minibuf.c b/src/minibuf.c index b40d1fbafc..cffb7fe787 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -2271,6 +2271,13 @@ If no minibuffer is active, return nil. */) +void +set_initial_minibuffer_mode (void) +{ + Lisp_Object minibuf = get_minibuffer (0); + set_minibuffer_mode (minibuf, 0); +} + static void init_minibuf_once_for_pdumper (void); void @@ -2279,6 +2286,8 @@ init_minibuf_once (void) staticpro (&Vminibuffer_list); staticpro (&Vcommand_loop_level_list); pdumper_do_now_and_after_load (init_minibuf_once_for_pdumper); + /* Ensure our inactive minibuffer exists. */ + get_minibuffer (0); } static void @@ -2296,9 +2305,6 @@ init_minibuf_once_for_pdumper (void) minibuf_prompt = Qnil; minibuf_save_list = Qnil; last_minibuf_string = Qnil; - /* Ensure our inactive minibuffer exists. */ - Lisp_Object minibuf = get_minibuffer (0); - set_minibuffer_mode (minibuf, 0); } void commit 46e4704e2abca4d264a43965f92eab7608211ee6 Author: Alan Mackenzie Date: Sat May 15 11:49:49 2021 +0000 Miscellaneous corrections to src/minibuf.c for bug #48337 * src/minibuf.c (read_minibuf): Call get_minibuffer before incrementing minibuf_level, in case a hook function calls Factive_minibuffer_window. (init_minibuf_once_for_pdumper): Create *Minibuf-0* here (moved from init_minibuf_once), and set its mode, so that clicking in the mini-window immediately after start up works (thanks, Eli Z.). diff --git a/src/minibuf.c b/src/minibuf.c index 428998a639..b40d1fbafc 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -653,11 +653,12 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, return unbind_to (count, val); } - minibuf_level++; /* Before calling choose_minibuf_frame. */ - /* Ensure now that the latest minibuffer has been created, in case - anything happens which depends on MINNIBUF_LEVEL and - Vminibuffer_list being consistent with eachother. */ - minibuffer = get_minibuffer (minibuf_level); + /* Ensure now that the latest minibuffer has been created and pushed + onto Vminibuffer_list before incrementing minibuf_level, in case + a hook called during the minibuffer creation calls + Factive_minibuffer_window. */ + minibuffer = get_minibuffer (minibuf_level + 1); + minibuf_level++; /* Before calling choose_minibuf_frame. */ /* Choose the minibuffer window and frame, and take action on them. */ @@ -2278,8 +2279,6 @@ init_minibuf_once (void) staticpro (&Vminibuffer_list); staticpro (&Vcommand_loop_level_list); pdumper_do_now_and_after_load (init_minibuf_once_for_pdumper); - /* Ensure our inactive minibuffer exists. */ - get_minibuffer (0); } static void @@ -2297,6 +2296,9 @@ init_minibuf_once_for_pdumper (void) minibuf_prompt = Qnil; minibuf_save_list = Qnil; last_minibuf_string = Qnil; + /* Ensure our inactive minibuffer exists. */ + Lisp_Object minibuf = get_minibuffer (0); + set_minibuffer_mode (minibuf, 0); } void commit 248ec838aa8b1a720a05b422be760f6ab32aa630 Author: Eli Zaretskii Date: Sat May 15 12:38:01 2021 +0300 Fix launching net-utils on MS-Windows * lisp/net/net-utils.el (net-utils-run-simple): Bind coding-system-for-read around the code which starts the process. (Bug#48375) diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 24f2aba8b8..90cca7d415 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -363,24 +363,24 @@ This variable is only used if the variable (when proc (set-process-filter proc nil) (delete-process proc))) - (let ((inhibit-read-only t) - (coding-system-for-read - ;; MS-Windows versions of network utilities output text - ;; encoded in the console (a.k.a. "OEM") codepage, which is - ;; different from the default system (a.k.a. "ANSI") - ;; codepage. - (if (eq system-type 'windows-nt) - (intern (format "cp%d" (w32-get-console-output-codepage))) - coding-system-for-read))) + (let ((inhibit-read-only t)) (erase-buffer)) (net-utils-mode) (setq-local net-utils--revert-cmd `(net-utils-run-simple ,(current-buffer) ,program-name ,args nodisplay)) - (set-process-filter - (apply #'start-process program-name - (current-buffer) program-name args) - #'net-utils-remove-ctrl-m-filter) + (let ((coding-system-for-read + ;; MS-Windows versions of network utilities output text + ;; encoded in the console (a.k.a. "OEM") codepage, which is + ;; different from the default system (a.k.a. "ANSI") + ;; codepage. + (if (eq system-type 'windows-nt) + (intern (format "cp%d" (w32-get-console-output-codepage))) + coding-system-for-read))) + (set-process-filter + (apply #'start-process program-name + (current-buffer) program-name args) + #'net-utils-remove-ctrl-m-filter)) (unless nodisplay (display-buffer (current-buffer))))) (defun net-utils--revert-function (&optional _ignore-auto _noconfirm) commit 0a681590268a4039f95a5a919b6b6d4f4e880d4c Author: pillule Date: Sat May 15 10:47:07 2021 +0200 Fix `quit-restore-window' when all previous buffers got killed (Bug#48367) * lisp/window.el (quit-restore-window): Simplify calculation of WINDOW's previous buffer. Avoid that killing WINDOW's previous buffers results in a state where `quit-window' has no more effect, by simply deleting WINDOW in that case (Bug#48367). Copyright-paperwork-exempt: yes diff --git a/lisp/window.el b/lisp/window.el index 8928308eb2..026cde5901 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5036,14 +5036,10 @@ nil means to not handle the buffer in a particular way. This (setq window (window-normalize-window window t)) (let* ((buffer (window-buffer window)) (quit-restore (window-parameter window 'quit-restore)) - (prev-buffer - (let* ((prev-buffers (window-prev-buffers window)) - (prev-buffer (caar prev-buffers))) - (and (or (not (eq prev-buffer buffer)) - (and (cdr prev-buffers) - (not (eq (setq prev-buffer (cadr prev-buffers)) - buffer)))) - prev-buffer))) + (prev-buffer (catch 'prev-buffer + (dolist (buf (window-prev-buffers window)) + (unless (eq (car buf) buffer) + (throw 'prev-buffer (car buf)))))) quad entry) (cond ((and (not prev-buffer) @@ -5114,7 +5110,10 @@ nil means to not handle the buffer in a particular way. This (set-window-parameter window 'quit-restore nil) ;; Make sure that WINDOW is no more dedicated. (set-window-dedicated-p window nil) - (switch-to-prev-buffer window bury-or-kill))) + (if prev-buffer + (switch-to-prev-buffer window bury-or-kill) + ;; Delete WINDOW if there is no previous buffer (Bug#48367). + (window--delete window nil (eq bury-or-kill 'kill))))) ;; Deal with the buffer. (cond