commit 0522049864951fcb1231e80725a3c8d7d88605c6 (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Fri Jul 7 09:33:56 2023 +0300 * lisp/tab-bar.el: Improve tab-bar-minibuffer-restore-tab (bug#64373). (tab-bar-select-tab): Set tab-bar-minibuffer-restore-tab and minibuffer-exit-hook minibuffer-locally to handle recursive minibuffers for non-nil read-minibuffer-restore-windows. (tab-bar-minibuffer-restore-tab): No need to reset minibuffer-local values. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 234e7e5d14d..f47c4a7bb6c 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1261,10 +1261,8 @@ tab-bar-minibuffer-restore-tab This is necessary to prepare the same window configuration where original windows were saved and will be restored. This function is used only when `read-minibuffer-restore-windows' is non-nil." - (when (and read-minibuffer-restore-windows - tab-bar-minibuffer-restore-tab) - (tab-bar-select-tab tab-bar-minibuffer-restore-tab) - (setq tab-bar-minibuffer-restore-tab nil))) + (when tab-bar-minibuffer-restore-tab + (tab-bar-select-tab tab-bar-minibuffer-restore-tab))) (defun tab-bar-select-tab (&optional tab-number) "Switch to the tab by its absolute position TAB-NUMBER in the tab bar. @@ -1293,8 +1291,8 @@ tab-bar-select-tab (when (and read-minibuffer-restore-windows minibuffer-was-active (not tab-bar-minibuffer-restore-tab)) - (setq tab-bar-minibuffer-restore-tab (1+ from-index)) - (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab)) + (setq-local tab-bar-minibuffer-restore-tab (1+ from-index)) + (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab nil t)) (unless (eq from-index to-index) (let* ((from-tab (tab-bar--tab)) commit 3cea0a84900176bca60586d21c6a556056b4292c Author: Harald Jörg Date: Thu Jul 6 17:29:42 2023 +0200 ; cperl-mode: Refine syntax of attributes Attributes may start with underscore, and must be separated. Thanks to Mattias Engdegård for pointing out a regex mistake. * lisp/progmodes/cperl-mode.el (defconst): Fix bad grouping and allow attributes to start with an underscore in cperl--single-attribute-rx. Adjust cperl--attribute-list-rx accordingly. (cperl-find-sub-attrs): Allow attributes to start with an underscore. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-attribute-list-rx): Add new test cases for valid and invalid attribute lists. diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 809a7274a25..c0e9cfde8e7 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1305,23 +1305,33 @@ cperl-menu "A sequence for recommended version number schemes in Perl.") (defconst cperl--single-attribute-rx - `(sequence word-start - ,cperl--basic-identifier-rx + `(sequence ,cperl--basic-identifier-rx (optional (sequence "(" - (0+ (not (in ")"))) - ")"))) + (0+ (or (sequence "\\" not-newline) + (not (any "()\\")) + (sequence "(" + (zero-or-more + (not + (any "()\\"))) + ")"))) + ")"))) "A regular expression for a single attribute, without leading colon. -It may have parameters in parens, but parens within the -parameter's value are not supported. This regexp does not have +It may have parameters in parens, one level of parens within the +parameter's value is supported. This regexp does not have capture groups.") (defconst cperl--attribute-list-rx `(sequence ":" - (0+ (sequence - ,cperl--ws*-rx - ,cperl--single-attribute-rx - ,cperl--ws*-rx - (optional ":")))) + (optional + ,cperl--ws*-rx + ,cperl--single-attribute-rx + (0+ (sequence + (or (sequence ,cperl--ws*-rx + ":" + ,cperl--ws*-rx) + ,cperl--ws+-rx) + ,cperl--single-attribute-rx)) + (optional ":"))) "A regular expression for an attribute list. Attribute lists may only occur in certain declarations. A colon is required before the first attribute but optional between @@ -3607,7 +3617,7 @@ cperl-find-sub-attrs "\\)" (if after-first "?" "") ;; No space between name and paren allowed... - "\\(\\sw+\\)" ; 3=name + (rx (group (eval cperl--basic-identifier-rx))) ; 3=name "\\((\\)?")) ; 4=optional paren (and (match-beginning 1) (cperl-postpone-fontification diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 211587cabac..eaf228cb2e2 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -484,12 +484,16 @@ cperl-test-attribute-list-rx (skip-unless (eq cperl-test-mode #'cperl-mode)) (let ((valid '(":" ":foo" ": bar()" ":baz(quux):" - ":isa(Foo)does(Bar)" ":isa(Foo):does(Bar)" ":isa(Foo):does(Bar):" + ":_" ":_foo" + ":isa(Foo) does(Bar)" ":isa(Foo):does(Bar)" + ":isa(Foo):does(Bar):" ": isa(Foo::Bar) : does(Bar)")) (invalid '(":foo + bar" ; not an identifier + "::foo" ; not an attribute list ": foo(bar : : baz" ; too many colons - ": baz (quux)"))) ; no space allowed before "(" + ": foo(bar)baz" ; need a separator + ": baz (quux)"))) ; no space allowed before "(" (cperl-test--validate-regexp (rx (eval cperl--attribute-list-rx)) valid invalid))) commit 65c90040eb08cd551120eda0e6647b59b25563d5 Author: Eli Zaretskii Date: Thu Jul 6 18:00:05 2023 +0300 Revert "Use 'emacs-lisp-compilation-mode' in native compilation buffers" This reverts commit 40492581f96626e405e4b453456b8c9b83822c97. It caused a recursive-load error when native-compiling files. (Bug#64391) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 77584b692a4..22fb08e4688 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1133,8 +1133,7 @@ comp-log-to-buffer (log-buffer (or (get-buffer comp-log-buffer-name) (with-current-buffer (get-buffer-create comp-log-buffer-name) - (unless (derived-mode-p 'compilation-mode) - (emacs-lisp-compilation-mode)) + (setf buffer-read-only t) (current-buffer)))) (log-window (get-buffer-window log-buffer)) (inhibit-read-only t) @@ -4086,8 +4085,7 @@ comp-run-async-workers :buffer (with-current-buffer (get-buffer-create comp-async-buffer-name) - (unless (derived-mode-p 'compilation-mode) - (emacs-lisp-compilation-mode)) + (setf buffer-read-only t) (current-buffer)) :command (list (expand-file-name invocation-name @@ -4121,8 +4119,6 @@ comp-run-async-workers (run-hooks 'native-comp-async-all-done-hook) (with-current-buffer (get-buffer-create comp-async-buffer-name) (save-excursion - (unless (derived-mode-p 'compilation-mode) - (emacs-lisp-compilation-mode)) (let ((inhibit-read-only t)) (goto-char (point-max)) (insert "Compilation finished.\n")))) commit 40492581f96626e405e4b453456b8c9b83822c97 Author: Eli Zaretskii Date: Thu Jul 6 11:50:41 2023 +0300 Use 'emacs-lisp-compilation-mode' in native compilation buffers * lisp/emacs-lisp/comp.el (comp-log-to-buffer) (comp-run-async-workers): Use 'emacs-lisp-compilation-mode' in the buffers where we log the results of native compilation. Suggested by No Wayman . (Bug#64452) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 22fb08e4688..77584b692a4 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1133,7 +1133,8 @@ comp-log-to-buffer (log-buffer (or (get-buffer comp-log-buffer-name) (with-current-buffer (get-buffer-create comp-log-buffer-name) - (setf buffer-read-only t) + (unless (derived-mode-p 'compilation-mode) + (emacs-lisp-compilation-mode)) (current-buffer)))) (log-window (get-buffer-window log-buffer)) (inhibit-read-only t) @@ -4085,7 +4086,8 @@ comp-run-async-workers :buffer (with-current-buffer (get-buffer-create comp-async-buffer-name) - (setf buffer-read-only t) + (unless (derived-mode-p 'compilation-mode) + (emacs-lisp-compilation-mode)) (current-buffer)) :command (list (expand-file-name invocation-name @@ -4119,6 +4121,8 @@ comp-run-async-workers (run-hooks 'native-comp-async-all-done-hook) (with-current-buffer (get-buffer-create comp-async-buffer-name) (save-excursion + (unless (derived-mode-p 'compilation-mode) + (emacs-lisp-compilation-mode)) (let ((inhibit-read-only t)) (goto-char (point-max)) (insert "Compilation finished.\n")))) commit 193031299231a026b8c855eff213fc63be28692d Author: Spencer Baugh Date: Fri Apr 7 17:54:06 2023 -0400 ; * etc/NEWS: News entry for previous change (bug#62164). diff --git a/etc/NEWS b/etc/NEWS index ab975da5e7f..1a86c9e55e2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -168,6 +168,16 @@ This allows changing which type of whitespace changes are ignored when regenerating hunks with 'diff-ignore-whitespace-hunk'. Defaults to the previously hard-coded "-b". +** Ediff + +--- +*** New user option 'ediff-floating-control-frame'. +If non-nil, try making the control frame be floating rather than tiled. + +Many X tiling window managers make the Ediff control frame a tiled +window equal in size to the main Emacs frame, which works poorly. +This option is useful to set if you use such a window manager. + ** Buffer Selection --- commit e02d0b554e70b8e2170c8eb4411608ef54e7de1d Author: Spencer Baugh Date: Fri Apr 7 17:54:06 2023 -0400 Allow floating the ediff control frame under X This is a step in the direction of making ediff behave better by default under tiling window managers and fixing Bug#62164. * lisp/vc/ediff-wind.el (ediff-floating-control-frame): Add defcustom. (ediff-frame-make-utility, ediff-setup-control-frame): Allow setting the control frame up as a utility window under X. (Bug#62164) diff --git a/lisp/vc/ediff-wind.el b/lisp/vc/ediff-wind.el index eb903f093f9..3077c562d63 100644 --- a/lisp/vc/ediff-wind.el +++ b/lisp/vc/ediff-wind.el @@ -69,6 +69,16 @@ ediff-window-setup-function (function :tag "Other function")) :version "24.3") +(defcustom ediff-floating-control-frame nil + "If non-nil, try making the control frame be floating rather than tiled. + +If your X window manager makes the Ediff control frame a tiled one, +set this to a non-nil value, and Emacs will try to make it floating. +This only has effect on X displays." + :type '(choice (const :tag "Control frame floats" t) + (const :tag "Control frame has default WM behavior" nil)) + :version "30.1") + (ediff-defvar-local ediff-multiframe nil "Indicates if we are in a multiframe setup.") @@ -873,6 +883,16 @@ ediff-window-ok-for-display (not (ediff-frame-has-dedicated-windows (window-frame wind))) ))) +(defun ediff-frame-make-utility (frame) + (let ((x-fast-protocol-requests t)) + (x-change-window-property + "_NET_WM_WINDOW_TYPE" '("_NET_WM_WINDOW_TYPE_UTILITY") + frame "ATOM" 32 t) + (x-change-window-property + "WM_TRANSIENT_FOR" + (list (string-to-number (frame-parameter nil 'window-id))) + frame "WINDOW" 32 t))) + ;; Prepare or refresh control frame (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame) (let ((window-min-height 1) @@ -948,6 +968,8 @@ ediff-setup-control-frame (goto-char (point-min)) (modify-frame-parameters ctl-frame adjusted-parameters) + (when (and ediff-floating-control-frame (eq (window-system ctl-frame) 'x)) + (ediff-frame-make-utility ctl-frame)) (make-frame-visible ctl-frame) ;; This works around a bug in 19.25 and earlier. There, if frame gets commit ea845e3fcd1d784c2f86595ff43f3fb37fd081ef Author: Eli Zaretskii Date: Thu Jul 6 10:33:43 2023 +0300 ; * etc/NEWS: Fix punctuation and whitespace of last added entry. diff --git a/etc/NEWS b/etc/NEWS index 50fd1382866..ab975da5e7f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -92,9 +92,9 @@ plus, minus, check-mark, start, etc. The 'tool-bar-position' frame parameter can be set to 'bottom' on all window systems other than Nextstep. -** Modeline elements can now be right-aligned +** Modeline elements can now be right-aligned. Anything following the symbol 'mode-line-format-right-align' in -'mode-line-format' will be right-aligned. Exactly where it is +'mode-line-format' will be right-aligned. Exactly where it is right-aligned to is controlled by the new user option 'mode-line-right-align-edge'. commit c296bcc6c42ebb0fbc5078a137bbf6b501b8a44f Author: Hugo Heagren Date: Sat Apr 1 22:27:25 2023 +0100 Support right-align in mode-line * lisp/bindings.el (mode-line-right-align-edge): New custom variable, controls where `mode-line-format-right-align' should align to. (mode-line-format-right-align): New function. If the symbol `mode-line-format-right-align' appears in `mode-line-format', then return return a padding string which aligns everything after that symbol to the right. Padding width is altered with the display property and depends on the value of `mode-line-right-align-edge'. (mode-line-format-right-align): New variable. Convenience definition for including right alignment in `mode-line-format'. * doc/lispref/modes.texi (Mode Line Variables): Document new alignment functionality and user option. (Bug#62606) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 8ca0afe1bca..b4f69e79155 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2275,6 +2275,16 @@ Mode Line Variables @defvar mode-line-client This variable is used to identify @code{emacsclient} frames. +@end defvar + +@defvar mode-line-format-right-align +Anything following this symbol in @code{mode-line-format} will be +right-aligned. +@end defvar + +@defvar mode-line-right-align-edge +This variable controls exactly @code{mode-line-format-right-align} +aligns content to. @end defvar The following three variables are used in @code{mode-line-modes}: diff --git a/etc/NEWS b/etc/NEWS index e36e77fa97f..50fd1382866 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -92,6 +92,12 @@ plus, minus, check-mark, start, etc. The 'tool-bar-position' frame parameter can be set to 'bottom' on all window systems other than Nextstep. +** Modeline elements can now be right-aligned +Anything following the symbol 'mode-line-format-right-align' in +'mode-line-format' will be right-aligned. Exactly where it is +right-aligned to is controlled by the new user option +'mode-line-right-align-edge'. + * Editing Changes in Emacs 30.1 diff --git a/lisp/bindings.el b/lisp/bindings.el index c77b64c05da..f1a75b080be 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -304,6 +304,70 @@ mode-line-process ;;;###autoload (put 'mode-line-process 'risky-local-variable t) +(defcustom mode-line-right-align-edge 'window + "Where function `mode-line-format-right-align' should align to. +Internally, that function uses `:align-to' in a display property, +so aligns to the left edge of the given area. See info node +`(elisp)Pixel Specification'. + +Must be set to a symbol. Acceptable values are: +- `window': align to extreme right of window, regardless of margins + or fringes +- `right-fringe': align to right-fringe +- `right-margin': align to right-margin" + :type '(choice (const right-margin) + (const right-fringe) + (const window)) + :group 'mode-line + :version "30.1") + +(defun mode--line-format-right-align () + "Right-align all following mode-line constructs. + +When the symbol `mode-line-format-right-align' appears in +`mode-line-format', return a string of one space, with a display +property to make it appear long enough to align anything after +that symbol to the right of the rendered mode line. Exactly how +far to the right is controlled by `mode-line-right-align-edge'. + +It is important that the symbol `mode-line-format-right-align' be +included in `mode-line-format' (and not another similar construct +such as `(:eval (mode-line-format-right-align)'). This is because +the symbol `mode-line-format-right-align' is processed by +`format-mode-line' as a variable." + (let* ((rest (cdr (memq 'mode-line-format-right-align + mode-line-format))) + (rest-str (format-mode-line `("" ,@rest))) + (rest-width (string-pixel-width rest-str))) + (propertize " " 'display + ;; The `right' spec doesn't work on TTY frames + ;; when windows are split horizontally (bug#59620) + (if (and (display-graphic-p) + (not (eq mode-line-right-align-edge 'window))) + `(space :align-to (- ,mode-line-right-align-edge + (,rest-width))) + `(space :align-to (,(- (window-pixel-width) + (window-scroll-bar-width) + (window-right-divider-width) + (* (or (cdr (window-margins)) 1) + (frame-char-width)) + ;; Manually account for value of + ;; `mode-line-right-align-edge' even + ;; when display is non-graphical + (pcase mode-line-right-align-edge + ('right-margin + (or (cdr (window-margins)) 0)) + ('right-fringe + ;; what here? + (or (cadr (window-fringes)) 0)) + (_ 0)) + rest-width))))))) + +(defvar mode-line-format-right-align '(:eval (mode--line-format-right-align)) + "Mode line construct to right align all following constructs.") +;;;###autoload +(put 'mode-line-format-right-align 'risky-local-variable t) + (defun bindings--define-key (map key item) "Define KEY in keymap MAP according to ITEM from a menu. This is like `define-key', but it takes the definition from the commit 6295d7abdd43ed6611cc3dd0682d56265cbc4528 Author: Matthias Meulien Date: Sat Jul 1 22:12:43 2023 +0200 Improve Python imports management commands * lisp/progmodes/python.el (python--list-imports): Handle import errors. (python--do-isort): Specialize error message. (Bug#64406) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 50d712ebb0c..4291ab03ca6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6446,8 +6446,14 @@ python-flymake ;;; Import management (defconst python--list-imports "\ -from isort import find_imports_in_stream, find_imports_in_paths -from sys import argv, stdin +from sys import argv, exit, stdin + +try: + from isort import find_imports_in_stream, find_imports_in_paths +except ModuleNotFoundError: + exit(1) +except ImportError: + exit(2) query, files, result = argv[1] or None, argv[2:], {} @@ -6501,9 +6507,13 @@ python--list-imports (or name "") (mapcar #'file-local-name source))))) lines) - (unless (eq 0 status) + (cond + ((eq 1 status) (error "%s exited with status %s (maybe isort is missing?)" python-interpreter status)) + ((eq 2 status) + (error "%s exited with status %s (maybe isort version is <5.7.0?)" + python-interpreter status))) (goto-char (point-min)) (while (not (eobp)) (push (buffer-substring-no-properties (point) (pos-eol)) @@ -6546,9 +6556,13 @@ python--do-isort nil (list temp nil) nil "-m" "isort" "-" args)) (tick (buffer-chars-modified-tick))) - (unless (eq 0 status) + (cond + ((eq 1 status) (error "%s exited with status %s (maybe isort is missing?)" python-interpreter status)) + ((eq 2 status) + (error "%s exited with status %s (maybe isort version is <5.7.0?)" + python-interpreter status))) (replace-buffer-contents temp) (not (eq tick (buffer-chars-modified-tick)))))))))