commit 3d609375f99cd0d4b7a441802d4616bad385e31d (HEAD, refs/remotes/origin/master) Author: Daniel Colascione Date: Wed Oct 2 21:33:50 2024 -0700 Track nil colors in term Teach term the difference between an unset foreground or background color and a color that happens to match an existing color. This way, when we insert text after a color reset:(e.g. from an SGR0), we insert it without :foreground or :background (whichever we've reset) face properties, allowing that inserted text to inherit the colors of the underlying face. This way, if we change, e.g., the background color of a buffer, the background color of already-inserted text from the term child changes along with that of the buffer instead of being "locked" to whatever the background color of the buffer was at the time the text was inserted. This change aligns term.el with other terminal emulators. * lisp/term.el (term-ansi-current-color): (term--color-as-hex): track nil fg, bg colors diff --git a/lisp/term.el b/lisp/term.el index 9a8dc25e1a2..7b9886e720a 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -732,9 +732,9 @@ Buffer local variable.") (defvar term-ansi-current-underline nil) (defvar term-ansi-current-slow-blink nil) (defvar term-ansi-current-fast-blink nil) -(defvar term-ansi-current-color 0) +(defvar term-ansi-current-color nil) (defvar term-ansi-face-already-done nil) -(defvar term-ansi-current-bg-color 0) +(defvar term-ansi-current-bg-color nil) (defvar term-ansi-current-reverse nil) (defvar term-ansi-current-invisible nil) @@ -1084,9 +1084,9 @@ For custom keybindings purposes please note there is also (setq term-ansi-current-slow-blink nil) (setq term-ansi-current-fast-blink nil) (setq term-ansi-current-reverse nil) - (setq term-ansi-current-color 0) + (setq term-ansi-current-color nil) (setq term-ansi-current-invisible nil) - (setq term-ansi-current-bg-color 0)) + (setq term-ansi-current-bg-color nil)) (defvar touch-screen-display-keyboard) @@ -3430,19 +3430,21 @@ option is enabled. See `term-set-goto-process-mark'." (defun term--color-as-hex (for-foreground) "Return the current ANSI color as a hexadecimal color string. Use the current background color if FOR-FOREGROUND is nil, -otherwise use the current foreground color." +otherwise use the current foreground color. Return nil if the +color is unset in the terminal state." (let ((color (if for-foreground term-ansi-current-color term-ansi-current-bg-color))) - (or (ansi-color--code-as-hex (1- color)) - (progn - (and ansi-color-bold-is-bright term-ansi-current-bold - (<= 1 color 8) - (setq color (+ color 8))) - (if for-foreground - (face-foreground (elt ansi-term-color-vector color) - nil 'default) - (face-background (elt ansi-term-color-vector color) - nil 'default)))))) + (when color + (or (ansi-color--code-as-hex (1- color)) + (progn + (and ansi-color-bold-is-bright term-ansi-current-bold + (<= 1 color 8) + (setq color (+ color 8))) + (if for-foreground + (face-foreground (elt ansi-term-color-vector color) + nil 'default) + (face-background (elt ansi-term-color-vector color) + nil 'default))))))) ;; New function to deal with ansi colorized output, as you can see you can ;; have any bold/underline/fg/bg/reverse combination. -mm @@ -3499,7 +3501,7 @@ otherwise use the current foreground color." (_ (term-ansi-reset)))) ;; Reset foreground (terminfo: op) - (39 (setq term-ansi-current-color 0)) + (39 (setq term-ansi-current-color nil)) ;; Background (terminfo: setab) ((and param (guard (<= 40 param 47))) @@ -3529,7 +3531,7 @@ otherwise use the current foreground color." (_ (term-ansi-reset)))) ;; Reset background (terminfo: op) - (49 (setq term-ansi-current-bg-color 0)) + (49 (setq term-ansi-current-bg-color nil)) ;; 0 (Reset) (terminfo: sgr0) or unknown (reset anyway) (_ (term-ansi-reset)))) @@ -3541,10 +3543,10 @@ otherwise use the current foreground color." (setq fg (term--color-as-hex t) bg (term--color-as-hex nil))) (setq term-current-face - `( :foreground ,fg - :background ,bg - ,@(unless term-ansi-current-invisible - (list :inverse-video term-ansi-current-reverse))))) + `(,@(when fg `(:foreground ,fg)) + ,@(when bg `(:background ,bg)) + ,@(unless term-ansi-current-invisible + (list :inverse-video term-ansi-current-reverse))))) (setq term-current-face `(,term-current-face commit ad529831018555b4c693844bc3b18766eb78465a Author: Dmitry Gutov Date: Thu Oct 3 04:17:35 2024 +0300 Make xref-find-references work in Help buffers outside of projects * lisp/help-fns.el (xref-backend-references): New context-dependent override. Don't call project-current and use elisp-load-path-roots directly (bug#69462). (help-fns--setup-xref-backend): No need to set project-vc-external-roots-function then. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index c7667cb2dd7..40e589b3e0a 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -262,9 +262,21 @@ interactive command." fn)) (list fn))) +(declare-function project-combine-directories "project" (&rest lists)) + +(cl-defmethod xref-backend-references ((_backend (eql 'elisp)) identifier + &context (major-mode help-mode)) + (mapcan + (lambda (dir) + (message "Searching %s..." dir) + (redisplay) + (prog1 + (xref-references-in-directory identifier dir) + (message "Searching %s... done" dir))) + (project-combine-directories (elisp-load-path-roots)))) + (defun help-fns--setup-xref-backend () (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) - (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (setq-local semantic-symref-filepattern-alist '((help-mode "*.el")))) ;;;###autoload commit 11e7aa75eeba3c0d24d84782639b48c64c8e1ea3 Author: Sean Whitton Date: Thu Oct 3 08:50:55 2024 +0800 ; Rework documentation for diff-delete-other-hunks diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 67a1a3be3ff..0866e81233d 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1705,8 +1705,11 @@ diffs were applied successfully, save the changed buffers. @findex diff-delete-other-hunks @item C-c @key{RET} n -Delete all hunks other than the current hunk. If the region is active, -then delete all hunks that the region does not overlap. +Delete hunks other than the current one. If the region is active, this +command deletes the hunks the region overlaps; otherwise it deletes all +hunks other than the current hunk. This command does not work in a +narrowed buffer because deleting hunks safely requires access to the +file headers. @findex diff-refine-hunk @item C-c C-b diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 51e7d90f98b..df55ca2ad80 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -822,10 +822,12 @@ If the prefix ARG is given, restrict the view to the current file instead." ;; would be a patch with the same meaning. That is not implemented ;; because it does not seem like it would be useful. (defun diff-delete-other-hunks (&optional beg end) - "Delete all hunks other than the current hunk. -Interactively, if the region is active, then delete all hunks that the -region does not overlap. When called from Lisp, the optional arguments -BEG and END specify the region of hunks not to delete." + "Delete hunks other than the current one. +Interactively, if the region is active, delete all hunks that the region +overlaps; otherwise delete all hunks except the current one. +When calling from Lisp, pass BEG and END as the bounds of the region in +which to delete hunks; BEG and END omitted or nil means to delete all +the hunks but the one which contains point." (interactive (list (use-region-beginning) (use-region-end))) (when (buffer-narrowed-p) (user-error "Command is not safe in a narrowed buffer")) commit c8ecd7fa0da8a597250989430ac2b2465419f18e Author: Dmitry Gutov Date: Thu Oct 3 03:04:46 2024 +0300 Use Emacs Lisp xref backend in Lisp Help buffers * lisp/help-fns.el (help-fns--setup-xref-backend): New function (bug#69462). (describe-function, describe-variable): Use it here. * lisp/emacs-lisp/cl-extra.el (cl-describe-type): And here. * lisp/progmodes/elisp-mode.el (xref-backend-definitions): Only infer namespace in emacs-lisp-mode (use 'any' otherwise). diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index 19429ce80df..4108512b3fa 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -733,6 +733,8 @@ PROPLIST is a list of the sort returned by `symbol-plist'. Call `cl--find-class' to get TYPE's propname `cl--class'" (cl--find-class type)) +(declare-function help-fns--setup-xref-backend "help-fns" ()) + ;;;###autoload (defun cl-describe-type (type &optional _buf _frame) "Display the documentation for type TYPE (a symbol)." @@ -753,6 +755,7 @@ Call `cl--find-class' to get TYPE's propname `cl--class'" ;; cl-deftype). (user-error "Unknown type %S" type)))) (with-current-buffer standard-output + (help-fns--setup-xref-backend) ;; Return the text we displayed. (buffer-string))))) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index e1daa8977f0..c7667cb2dd7 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -262,6 +262,11 @@ interactive command." fn)) (list fn))) +(defun help-fns--setup-xref-backend () + (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) + (setq-local project-vc-external-roots-function #'elisp-load-path-roots) + (setq-local semantic-symref-filepattern-alist '((help-mode "*.el")))) + ;;;###autoload (defun describe-function (function) "Display the full documentation of FUNCTION (a symbol). @@ -295,6 +300,8 @@ handling of autoloaded functions." (princ " is ") (describe-function-1 function) (with-current-buffer standard-output + (help-fns--setup-xref-backend) + ;; Return the text we displayed. (buffer-string)))))) @@ -1510,6 +1517,7 @@ it is displayed along with the global value." (delete-char 1))))) (with-current-buffer standard-output + (help-fns--setup-xref-backend) ;; Return the text we displayed. (buffer-string)))))))) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 63bd685af91..2f931daedc7 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1049,7 +1049,9 @@ namespace but with lower confidence." (let ((sym (intern-soft identifier))) (when sym (let* ((pos (get-text-property 0 'pos identifier)) - (namespace (if pos + (namespace (if (and pos + ;; Reusing it in Help Mode. + (derived-mode-p 'emacs-lisp-mode)) (elisp--xref-infer-namespace pos) 'any)) (defs (elisp--xref-find-definitions sym))) commit 79d66b4b2970b915abfde516d867107afa19348f Author: Daniel Colascione Date: Wed Oct 2 10:34:52 2024 -0700 Process focus-in events immediately on NS * src/nsterm.m ([EmacsView windowDidBecomeKey]): kick the main event loop when we get a focus-in event so it gets processed immediately (Bug#73559). diff --git a/src/nsterm.m b/src/nsterm.m index 8c405738467..f68a22d9fbc 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7973,6 +7973,7 @@ - (void)windowDidBecomeKey /* for direct calls */ event.kind = FOCUS_IN_EVENT; XSETFRAME (event.frame_or_window, emacsframe); kbd_buffer_store_event (&event); + ns_send_appdefined (-1); // Kick main loop } commit 4bb62af3263057312021e076dc7e0c8ff195e38f Author: Stefan Kangas Date: Wed Oct 2 12:19:22 2024 +0200 Prefer defcustom :local specifier in textmodes * lisp/textmodes/fill.el (default-justification): * lisp/textmodes/ispell.el (ispell-local-dictionary) (ispell-skip-html): * lisp/textmodes/less-css-mode.el (less-css-output-file-name) (less-css-input-file-name): * lisp/textmodes/refer.el (refer-bib-directory, refer-bib-files) (refer-cache-bib-files): * lisp/textmodes/two-column.el (2C-separator, 2C-window-width): Prefer defcustom :local specifier to using 'make-variable-buffer-local' directly. diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 29c56f8feaf..11c67d2dc51 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -1115,9 +1115,9 @@ The `justification' text-property can locally override this variable." (const right) (const full) (const center) - (const none)) + (const none)) + :local t :safe 'symbolp) -(make-variable-buffer-local 'default-justification) (defun current-justification () "How should we justify this line? diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 99f9e10a5a8..35550d1bbc4 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -346,12 +346,11 @@ calling \\[ispell-change-dictionary] with that value. This variable is automatically set when defined in the file with either `ispell-dictionary-keyword' or the Local Variable syntax." :type '(choice string - (const :tag "default" nil))) + (const :tag "default" nil)) + :local t) ;;;###autoload (put 'ispell-local-dictionary 'safe-local-variable 'string-or-null-p) -(make-variable-buffer-local 'ispell-local-dictionary) - (defcustom ispell-dictionary nil "Default dictionary to use if `ispell-local-dictionary' is nil." :type '(choice string @@ -377,10 +376,8 @@ such as \"&\". See `ispell-html-skip-alists' for more details. This variable affects spell-checking of HTML, XML, and SGML files." :type '(choice (const :tag "always" t) (const :tag "never" nil) - (const :tag "use-mode-name" use-mode-name))) - -(make-variable-buffer-local 'ispell-skip-html) - + (const :tag "use-mode-name" use-mode-name)) + :local t) (defcustom ispell-local-dictionary-alist nil "List of local or customized dictionary definitions. diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode.el index 51e62a712b4..27c94f625fc 100644 --- a/lisp/textmodes/less-css-mode.el +++ b/lisp/textmodes/less-css-mode.el @@ -115,8 +115,8 @@ This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the value of `less-css-output-dir', if set, or the current directory by default." - :type '(choice (const :tag "Default" nil) file)) -(make-variable-buffer-local 'less-css-output-file-name) + :type '(choice (const :tag "Default" nil) file) + :local t) (defcustom less-css-input-file-name nil "File name which will be compiled to CSS. @@ -131,10 +131,10 @@ variables. This can be also be set to a full path, or a relative path. If the path is relative, it will be relative to the current directory by default." - :type '(choice (const nil) file)) + :type '(choice (const nil) file) + :local t) ;;;###autoload (put 'less-css-input-file-name 'safe-local-variable #'stringp) -(make-variable-buffer-local 'less-css-input-file-name) (defconst less-css-default-error-regex "^\\(?:\e\\[31m\\)?\\([^\e\n]*\\|FileError:.*\n\\)\\(?:\e\\[39m\e\\[31m\\)? in \\(?:\e\\[39m\\)?\\([^ \r\n\t\e]+\\)\\(?:\e\\[90m\\)?\\(?::\\| on line \\)\\([0-9]+\\)\\(?::\\|, column \\)\\([0-9]+\\):?\\(?:\e\\[39m\\)?") diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el index f5f4be75c03..b6707d53071 100644 --- a/lisp/textmodes/refer.el +++ b/lisp/textmodes/refer.el @@ -91,7 +91,8 @@ the default search path. Since Refer does not know that default path, it cannot search it. Include that path explicitly in your BIBINPUTS environment if you really want it searched (which is not likely to happen anyway)." - :type '(choice (repeat directory) (const bibinputs) (const texinputs))) + :type '(choice (repeat directory) (const bibinputs) (const texinputs)) + :local t) (defcustom refer-bib-files 'dir "List of \\.bib files to search for references, @@ -109,14 +110,16 @@ If `refer-bib-files' is nil, auto or dir, it is setq'd to the appropriate list of files when it is first used if `refer-cache-bib-files' is t. If `refer-cache-bib-files' is nil, the list of \\.bib files to use is re-read each time it is needed." - :type '(choice (repeat file) (const nil) (const auto) (const dir))) + :type '(choice (repeat file) (const nil) (const auto) (const dir)) + :local t) (defcustom refer-cache-bib-files t "Variable determining whether the value of `refer-bib-files' should be cached. If t, initialize the value of refer-bib-files the first time it is used. If nil, re-read the list of \\.bib files depending on the value of `refer-bib-files' each time it is needed." - :type 'boolean) + :type 'boolean + :local t) (defcustom refer-bib-files-regexp "\\\\bibliography" "Regexp matching a bibliography file declaration. @@ -130,10 +133,6 @@ If a specified file doesn't exist and has no extension, a \\.bib extension is automatically tried." :type 'regexp) -(make-variable-buffer-local 'refer-bib-files) -(make-variable-buffer-local 'refer-cache-bib-files) -(make-variable-buffer-local 'refer-bib-directory) - ;;; Internal variables (defvar refer-saved-state nil) (defvar refer-previous-keywords nil) diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el index 806d6c5e709..41cd82ce728 100644 --- a/lisp/textmodes/two-column.el +++ b/lisp/textmodes/two-column.el @@ -142,15 +142,14 @@ (defcustom 2C-separator "" "A string inserted between the two columns when merging. This gets set locally by \\[2C-split]." - :type 'string) -(put '2C-separator 'permanent-local t) + :type 'string + :local 'permanent-only) (defcustom 2C-window-width 40 "The width of the first column. (Must be at least `window-min-width'.) This value is local for every buffer that sets it." - :type 'integer) -(make-variable-buffer-local '2C-window-width) -(put '2C-window-width 'permanent-local t) + :type 'integer + :local 'permanent) (defcustom 2C-beyond-fill-column 4 "Base for calculating `fill-column' for a buffer in two-column minor mode. commit 67e807d897077b7c982104b528e2504591214a29 Author: Stefan Kangas Date: Wed Oct 2 11:53:30 2024 +0200 ; Fix thinko in my last change * lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): Fix thinko. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defcustom-local): Update test. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 72953502f51..29e7882c851 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -5472,7 +5472,7 @@ FORM is used to provide location, `bytecomp--cus-function' and ;; Check :local (when-let ((val (and (eq fun 'custom-declare-variable) (plist-get keyword-args :local))) - (_ (not (memq val '(t permanent permanent-only))))) + (_ (not (member val '(t 'permanent 'permanent-only))))) (bytecomp--cus-warn form ":local keyword does not accept %S" val)))) (byte-compile-normal-call form)) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 69918e9c0c3..caece633459 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -1991,6 +1991,9 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode python-mode)) \ (rx ":local keyword does not accept 'symbol") (dc 'symbol)) (bytecomp--with-warning-test (rx ":local keyword does not accept \"string\"") (dc "string")) + (bytecomp--without-warning-test (dc t)) + (bytecomp--without-warning-test (dc 'permanent)) + (bytecomp--without-warning-test (dc 'permanent-only)) )) (ert-deftest bytecomp-test-defface-spec () commit 9e51815265b9837a8311ee28af39e6b78dd18e29 Author: Sean Whitton Date: Wed Oct 2 15:23:06 2024 +0800 New function shell-command-do-open * lisp/dired-aux.el (shell-command-do-open): Factor out of dired-do-open. (dired-do-open): Call shell-command-do-open. * etc/NEWS: Announce the new function. diff --git a/etc/NEWS b/etc/NEWS index 6262405cdd2..abe316547aa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -572,6 +572,13 @@ the first clause that matches will cause its body to be evaluated. users might find less cryptic. See the Info node "(elisp) cond* Macro" for details. +--- +** New function 'shell-command-do-open'. +This lets a Lisp program access the core functionality of the +'dired-do-open' command. It opens a file or files using an external +program, choosing the program according to the operating system's +conventions. + * Changes in Emacs 31.1 on Non-Free Operating Systems diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 15bd5c407b9..7fe67eed1e0 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1451,21 +1451,11 @@ This excludes `dired-guess-shell-alist-user' and (declare-function w32-shell-execute "w32fns.c") ;;;###autoload -(defun dired-do-open (&optional arg) - "Open all marked (or next ARG) files using an external program. +(defun shell-command-do-open (files) + "Open each of FILES using an external program. This \"opens\" the file(s) using the external command that is most -appropriate for the file(s) according to the system conventions. -If files are marked, run the command on each marked file. Otherwise, -run it on the next ARG files, or on the file at mouse-click, or on the -file at point. The appropriate command to \"open\" a file on each -system is determined by `shell-command-guess-open'." - (interactive "P" dired-mode) - (let ((files (if (mouse-event-p last-nonmenu-event) - (save-excursion - (mouse-set-point last-nonmenu-event) - (dired-get-marked-files nil arg)) - (dired-get-marked-files nil arg))) - (command shell-command-guess-open)) +appropriate for the file(s) according to the system conventions." + (let ((command shell-command-guess-open)) (when (and (memq system-type '(windows-nt)) (equal command "start")) (setq command "open")) @@ -1488,6 +1478,22 @@ system is determined by `shell-command-guess-open'." (call-process command nil 0 nil file)))) (error "Open not supported on this system")))) +;;;###autoload +(defun dired-do-open (&optional arg) + "Open all marked (or next ARG) files using an external program. +This \"opens\" the file(s) using the external command that is most +appropriate for the file(s) according to the system conventions. +If files are marked, run the command on each marked file. Otherwise, +run it on the next ARG files, or on the file at mouse-click, or on the +file at point. The appropriate command to \"open\" a file on each +system is determined by `shell-command-guess-open'." + (interactive "P" dired-mode) + (shell-command-do-open (if (mouse-event-p last-nonmenu-event) + (save-excursion + (mouse-set-point last-nonmenu-event) + (dired-get-marked-files nil arg)) + (dired-get-marked-files nil arg)))) + ;;; Commands that delete or redisplay part of the dired buffer