commit 6a390fd42ec4ef97d637899fc93f34ea65639e3c (HEAD, refs/remotes/origin/master) Author: Mattias Engdegård Date: Fri Dec 16 12:17:33 2022 +0100 Use equal and member instead of eq and memq * lisp/cedet/semantic/complete.el (semantic-displayer-show-request): * lisp/descr-text.el (describe-char-categories): * lisp/mh-e/mh-identity.el (mh-select-identity): * lisp/transient.el (transient--delay-post-command) (transient--post-command): * lisp/vc/vc-git.el (vc-git-create-tag): * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-nth-value-test-multiple-values): * lisp/emulation/viper-cmd.el (viper-preserve-cursor-color): Use `equal` instead of `eq` and `member` instead of `memq` where the comparison is with literals without guaranteed identity. In some cases this change corrects evident bugs, in others it is mostly cosmetic. diff --git a/lisp/cedet/semantic/complete.el b/lisp/cedet/semantic/complete.el index 00fe081acb5..1f372804dcc 100644 --- a/lisp/cedet/semantic/complete.el +++ b/lisp/cedet/semantic/complete.el @@ -1731,7 +1731,7 @@ semantic-displayer-show-request ;; Add any tail info. (setq msg (concat msg msg-tail)) ;; Display tooltip. - (when (not (eq msg "")) + (when (not (equal msg "")) (semantic-displayer-tooltip-show msg))))) ;;; Compatibility diff --git a/lisp/descr-text.el b/lisp/descr-text.el index f2ffddcf702..f105f292448 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -366,7 +366,7 @@ describe-char-padded-string ;; description is added to the category name as a tooltip (defsubst describe-char-categories (category-set) (let ((mnemonics (category-set-mnemonics category-set))) - (unless (eq mnemonics "") + (unless (equal mnemonics "") (list (mapconcat (lambda (x) (let* ((c (category-docstring x)) diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 26793989d05..3b3caaf3e3c 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -194,9 +194,9 @@ viper-preserve-cursor-color viper-delete-backward-char viper-join-lines viper-delete-char)) - (memq (viper-event-key last-command-event) - '(up down left right (meta f) (meta b) - (control n) (control p) (control f) (control b))))) + (member (viper-event-key last-command-event) + '(up down left right (meta f) (meta b) + (control n) (control p) (control f) (control b))))) (defsubst viper-insert-state-pre-command-sentinel () (or (viper-preserve-cursor-color) diff --git a/lisp/mh-e/mh-identity.el b/lisp/mh-e/mh-identity.el index bcdf91299be..2507c677462 100644 --- a/lisp/mh-e/mh-identity.el +++ b/lisp/mh-e/mh-identity.el @@ -141,7 +141,7 @@ mh-select-identity (cons '("None") (mapcar #'list (mapcar #'car mh-identity-list))) nil t default nil default)) - (if (eq identity "None") + (if (equal identity "None") nil identity))) diff --git a/lisp/transient.el b/lisp/transient.el index 1cab697eecb..01c492c68c1 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -2203,7 +2203,7 @@ transient--delay-post-command (unless abort-only (setq post-command (lambda () "@transient--delay-post-command" - (let ((act (and (not (eq (this-command-keys-vector) [])) + (let ((act (and (not (equal (this-command-keys-vector) [])) (or (eq this-command command) ;; `execute-extended-command' was ;; used to call another command @@ -2241,7 +2241,7 @@ transient--post-command (transient--debug 'post-command) (transient--with-emergency-exit (cond - ((and (eq (this-command-keys-vector) []) + ((and (equal (this-command-keys-vector) []) (= (minibuffer-depth) (1+ transient--minibuffer-depth))) (transient--suspend-override) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 2876a983fb0..9f27f759d35 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1674,7 +1674,8 @@ vc-git-create-tag (if branchp "branch" "tag")))) (if branchp (vc-git-command nil 0 nil "checkout" "-b" name - (when (and start-point (not (eq start-point ""))) + (when (and start-point + (not (equal start-point ""))) start-point)) (vc-git-command nil 0 nil "tag" name))))) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index b19494af746..c3c04b6305e 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -404,7 +404,7 @@ cl-lib-test-nth-value (ert-deftest cl-lib-nth-value-test-multiple-values () "While CL multiple values are an alias to list, these won't work." :expected-result :failed - (should (eq (cl-nth-value 0 '(2 3)) '(2 3))) + (should (equal (cl-nth-value 0 '(2 3)) '(2 3))) (should (= (cl-nth-value 0 1) 1)) (should (null (cl-nth-value 1 1))) (should-error (cl-nth-value -1 (cl-values 2 3)) :type 'args-out-of-range) commit 6283b9233459d74f95e9b0300f025a49f9674fb9 Author: Mattias Engdegård Date: Fri Dec 16 15:56:04 2022 +0100 Elide broken but unnecessary `if` optimisations * lisp/emacs-lisp/byte-opt.el (byte-optimize-if): Remove explicit clauses purposing to simplify (if X nil t) -> (not X) (if X t nil) -> (not (not X)) but never did so because of a coding mistake (eq instead of equal), found by a recently added warning. They weren't actually needed thanks to the optimiser's fixpoint iteration: we eventually get the same results through (if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X) (if X t nil) -> (if X t) -> (not (not X)) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 55b68c58438..898dfffef63 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1298,11 +1298,8 @@ byte-optimize-if (if else `(progn ,condition ,@else) condition)) - ;; (if X nil t) -> (not X) - ((and (eq then nil) (eq else '(t))) - `(not ,condition)) - ;; (if X t [nil]) -> (not (not X)) - ((and (eq then t) (or (null else) (eq else '(nil)))) + ;; (if X t) -> (not (not X)) + ((and (eq then t) (null else)) `(not ,(byte-opt--negate condition))) ;; (if VAR VAR X...) -> (or VAR (progn X...)) ((and (symbolp condition) (eq condition then)) commit 30d2b72c4124b351026a8a5420686d5dc04ecc61 Author: Mattias Engdegård Date: Fri Dec 16 11:08:02 2022 +0100 alist-get testfn argument evaluation correction * lisp/emacs-lisp/gv.el (alist-get): Evaluate TESTFN exactly once (previously up to 3 times). Reduce the macro-expansion to include a call to either assoc or assq, not both; this reduces the generated code size in some cases. diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 11251d7a963..48bc0269f36 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -417,9 +417,9 @@ alist-get (lambda (do key alist &optional default remove testfn) (macroexp-let2 macroexp-copyable-p k key (gv-letplace (getter setter) alist - (macroexp-let2 nil p `(if (and ,testfn (not (eq ,testfn 'eq))) - (assoc ,k ,getter ,testfn) - (assq ,k ,getter)) + (macroexp-let2 nil p (if (member testfn '(nil 'eq #'eq)) + `(assq ,k ,getter) + `(assoc ,k ,getter ,testfn)) (funcall do (if (null default) `(cdr ,p) `(if ,p (cdr ,p) ,default)) (lambda (v) commit 8624734504af4572525665c713a47e1b6f439a2c Author: Juanma Barranquero Date: Fri Dec 16 18:36:42 2022 +0100 ; * lisp/bs.el: Small doc and whitespace fixes diff --git a/lisp/bs.el b/lisp/bs.el index c976ed283c4..2823e87a9f4 100644 --- a/lisp/bs.el +++ b/lisp/bs.el @@ -321,7 +321,7 @@ bs-string-marked :group 'bs-appearance :type 'string) -(defcustom bs-string-show-normally " " +(defcustom bs-string-show-normally " " "String added in column 1 indicating an unmarked buffer." :group 'bs-appearance :type 'string) @@ -384,12 +384,12 @@ bs-define-sort-function "Define a new function for buffer sorting in Buffer Selection Menu. NAME specifies the sort order defined by function FUN. A value of nil for FUN means don't sort the buffer list. Otherwise the -functions must have two parameters - the buffers to compare. +function must have two arguments - the buffers to compare. REGEXP-FOR-SORTING is a regular expression which describes the column title to highlight. FACE is a face used to fontify the sorted column title. A value of nil means don't highlight. -The new sort aspect will be inserted into list `bs-sort-functions'." +The new sort aspect will be inserted into the list `bs-sort-functions'." (let ((tuple (assoc name bs-sort-functions))) (if tuple (setcdr tuple (list fun regexp-for-sorting face)) @@ -505,7 +505,7 @@ bs-default-action-list :version "30.1" :group 'bs) -; ---------------------------------------------------------------------- +;; ---------------------------------------------------------------------- ;; Functions ;; ---------------------------------------------------------------------- @@ -515,8 +515,8 @@ bs-buffer-list The result list depends on the global variables `bs-dont-show-regexp', `bs-must-show-regexp', `bs-dont-show-function', `bs-must-show-function' and `bs-buffer-sort-function'. -If SORT-DESCRIPTION isn't nil the list will be sorted by -a special function. SORT-DESCRIPTION is an element of `bs-sort-functions'." +If SORT-DESCRIPTION isn't nil the list will be sorted by a special +function. SORT-DESCRIPTION is an element of `bs-sort-functions'." (setq sort-description (or sort-description bs--current-sort-function) list (or list (buffer-list))) (let ((result nil)) @@ -582,9 +582,9 @@ bs--redisplay (beginning-of-line))) (defun bs--goto-current-buffer () - "Goto line which represents the current buffer; -actually the line which begins with character in `bs-string-current' or -`bs-string-current-marked'." + "Go to line which represents the current buffer. +Actually, it goes to the line which begins with the character +in `bs-string-current' or `bs-string-current-marked'." (let ((regexp (concat "^" (regexp-quote bs-string-current) "\\|^" @@ -836,9 +836,8 @@ bs-toggle-current-to-show (defun bs-set-current-buffer-to-show-always (&optional not-to-show-p) "Toggle status of buffer on line to `always shown'. -NOT-TO-SHOW-P: prefix argument. -With no prefix argument the buffer on current line is marked to show -always. Otherwise it is marked to show never." +With prefix argument NOT-TO-SHOW-P, the buffer on current line +is marked to never show instead." (interactive "P") (if not-to-show-p (bs-set-current-buffer-to-show-never) @@ -1247,8 +1246,6 @@ bs-cycle-next bs--cycle-list))) (next (car tuple)) (cycle-list (cdr tuple))) - ;; We don't want the frame iconified if the only window in the frame - ;; happens to be dedicated. (bury-buffer (current-buffer)) (switch-to-buffer next nil t) (setq bs--cycle-list (append (cdr cycle-list) @@ -1444,7 +1441,7 @@ bs--show-with-configuration (defun bs--configuration-name-for-prefix-arg (prefix) "Convert prefix argument PREFIX to a name of a buffer configuration. If PREFIX is nil return `bs-default-configuration'. -If PREFIX is an integer return PREFIX element of `bs-configurations'. +If PREFIX is an integer return PREFIXth element of `bs-configurations'. Otherwise return `bs-alternative-configuration'." (cond ;; usually activation ((null prefix) commit 12424cf31daec921e3b4a4029d99787d0e506f09 Author: Eli Zaretskii Date: Fri Dec 16 18:26:14 2022 +0200 New option for selecting symbols by double-clicking * lisp/mouse.el (mouse-1-double-click-prefer-symbols): New user option. (mouse-skip-word): If 'mouse-1-double-click-prefer-symbols' is non-nil, skip over the entire symbol at point. (Bug#60080) diff --git a/lisp/mouse.el b/lisp/mouse.el index f72ab4fc642..095d30a2856 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -105,6 +105,15 @@ mouse-1-click-in-non-selected-windows :type 'boolean :version "22.1") +(defcustom mouse-1-double-click-prefer-symbols nil + "If non-nil, double-clicking Mouse-1 attempts to select the symbol at click. + +If nil, the default, double-clicking Mouse-1 on a word-constituent +character will select only the word at click location, which could +select fewer characters than the symbol at click." + :type 'boolean + :version "30.1") + (defcustom mouse-drag-and-drop-region-scroll-margin nil "If non-nil, the scroll margin inside a window when dragging text. If the mouse moves this many lines close to the top or bottom of @@ -1800,10 +1809,17 @@ mouse--drag-set-mark-and-point ;; Commands to handle xterm-style multiple clicks. (defun mouse-skip-word (dir) "Skip over word, over whitespace, or over identical punctuation. +If `mouse-1-double-click-prefer-symbols' is non-nil, skip over symbol. If DIR is positive skip forward; if negative, skip backward." (let* ((char (following-char)) - (syntax (char-to-string (char-syntax char)))) - (cond ((string= syntax "w") + (syntax (char-to-string (char-syntax char))) + sym) + (cond ((and mouse-1-double-click-prefer-symbols + (setq sym (bounds-of-thing-at-point 'symbol))) + (goto-char (if (< dir 0) + (car sym) + (cdr sym)))) + ((string= syntax "w") ;; Here, we can't use skip-syntax-forward/backward because ;; they don't pay attention to word-separating-categories, ;; and thus they will skip over a true word boundary. So, commit b29be11a6f387c92508beafcbc8f58799a3e3e06 Author: Mattias Engdegård Date: Thu Dec 15 11:22:06 2022 +0100 Closures are always non-nil * lisp/emacs-lisp/byte-opt.el (byte-compile-trueconstp): Treat closures as true in boolean context. diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index a7e1df3622d..55b68c58438 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -755,7 +755,8 @@ byte-compile-trueconstp ((eq head 'list) (cdr form)) ((memq head ;; FIXME: Replace this list with a function property? - '( length safe-length cons lambda + '( lambda internal-make-closure + length safe-length cons string unibyte-string make-string concat format format-message substring substring-no-properties string-replace commit 9452dc4821a368fa4532423aaa1cc00034d8a139 Author: Stefan Monnier Date: Fri Dec 16 11:00:53 2022 -0500 tab-bar.el: Fix "void-function cl--set-substring" error * lisp/tab-bar.el: Use #' to quote function names. Try and fit within 80 columns. (tab-bar--load-buttons): Silence compiler warnings about `icons` functions. (tab-bar-auto-width): Avoid the use of `substring` as a gv-place because it requires `cl-lib` which we don't (want to) preload. [ Maybe a better solution would be to not preload tab-bar.el. ] diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index f040bc9786d..065116d5129 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -105,7 +105,7 @@ tab-bar-select-tab-modifiers (const hyper) (const super) (const alt)) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) ;; Reenable the tab-bar with new keybindings @@ -116,23 +116,23 @@ tab-bar-select-tab-modifiers :version "27.1") (defun tab-bar--define-keys () - "Install key bindings for switching between tabs if the user has configured them." + "Install key bindings to switch between tabs if so configured." (when tab-bar-select-tab-modifiers (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0))) - 'tab-recent) + #'tab-recent) (dotimes (i 8) (global-set-key (vector (append tab-bar-select-tab-modifiers (list (+ i 1 ?0)))) - 'tab-bar-select-tab)) + #'tab-bar-select-tab)) (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?9))) - 'tab-last)) + #'tab-last)) ;; Don't override user customized key bindings (unless (global-key-binding [(control tab)]) - (global-set-key [(control tab)] 'tab-next)) + (global-set-key [(control tab)] #'tab-next)) (unless (global-key-binding [(control shift tab)]) - (global-set-key [(control shift tab)] 'tab-previous)) + (global-set-key [(control shift tab)] #'tab-previous)) (unless (global-key-binding [(control shift iso-lefttab)]) - (global-set-key [(control shift iso-lefttab)] 'tab-previous)) + (global-set-key [(control shift iso-lefttab)] #'tab-previous)) ;; Replace default value with a condition that supports displaying ;; global-mode-string in the tab bar instead of the mode line. @@ -157,6 +157,9 @@ tab-bar--undefine-keys (defun tab-bar--load-buttons () "Load the icons for the tab buttons." (require 'icons) + (declare-function icon-string "icons" (name)) + (declare-function iconp "icons" (object)) + (declare-function icons--register "icons") (unless (iconp 'tab-bar-new) (define-icon tab-bar-new nil `((image "tabs/new.xpm" @@ -227,7 +230,8 @@ tab-bar--update-tab-bar-lines ;; Update `default-frame-alist' (when (eq frames t) (setq default-frame-alist - (cons (cons 'tab-bar-lines (if (and tab-bar-mode (eq tab-bar-show t)) 1 0)) + (cons (cons 'tab-bar-lines + (if (and tab-bar-mode (eq tab-bar-show t)) 1 0)) (assq-delete-all 'tab-bar-lines default-frame-alist))))) (define-minor-mode tab-bar-mode @@ -279,7 +283,8 @@ tab-bar--event-to-item ;; This code is used when you click the mouse in the tab bar ;; on a console which has no window system but does have a mouse. (let* ((x-position (car (posn-x-y posn))) - (keymap (lookup-key (cons 'keymap (nreverse (current-active-maps))) [tab-bar])) + (keymap (lookup-key (cons 'keymap (nreverse (current-active-maps))) + [tab-bar])) (column 0)) (when x-position (catch 'done @@ -478,7 +483,7 @@ tab-bar-show :type '(choice (const :tag "Always" t) (const :tag "When more than one tab" 1) (const :tag "Never" nil)) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (if val @@ -529,7 +534,7 @@ tab-bar-new-button-show "If non-nil, show the \"New tab\" button in the tab bar. When this is nil, you can create new tabs with \\[tab-new]." :type 'boolean - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -550,7 +555,7 @@ tab-bar-close-button-show (const :tag "On selected tab" selected) (const :tag "On non-selected tabs" non-selected) (const :tag "None" nil)) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -574,7 +579,7 @@ tab-bar-tab-hints This helps to select the tab by its number using `tab-bar-select-tab' and `tab-bar-select-tab-modifiers'." :type 'boolean - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -604,7 +609,7 @@ tab-bar-tab-name-function (const :tag "All window buffers" tab-bar-tab-name-all) (function :tag "Function")) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -704,7 +709,7 @@ tab-bar-tab-name-format-function Function gets two arguments, the tab and its number, and should return the formatted tab name to display in the tab bar." :type 'function - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -753,7 +758,7 @@ tab-bar-format tab-bar-format-add-tab tab-bar-format-align-right tab-bar-format-global) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -815,7 +820,8 @@ tab-bar--format-tab ,(alist-get 'binding tab) :help "Click to visit tab")))) (when (alist-get 'close-binding tab) - `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) + `((,(if (eq (car tab) 'current-tab) 'C-current-tab + (intern (format "C-tab-%i" i))) menu-item "" ,(alist-get 'close-binding tab)))))) @@ -832,7 +838,7 @@ tab-bar-tab-group-function "Function to get a tab group name. Function gets one argument: a tab." :type 'function - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -848,7 +854,7 @@ tab-bar-tab-group-format-function an optional value that is non-nil when the tab is from the current group. It should return the formatted tab group name to display in the tab bar." :type 'function - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (force-mode-line-update)) @@ -919,7 +925,8 @@ tab-bar-format-tabs-groups (when (and (not (equal previous-group tab-group)) tab-group) (tab-bar--format-tab-group tab i t)) ;; Override default tab faces to use group faces - (let ((tab-bar-tab-face-function tab-bar-tab-group-face-function)) + (let ((tab-bar-tab-face-function + tab-bar-tab-group-face-function)) (tab-bar--format-tab tab i)))) ;; Show first tab of other groups with a group name ((not (equal previous-group tab-group)) @@ -948,7 +955,8 @@ tab-bar-format-align-right ;; when windows are split horizontally (bug#59620) (if (window-system) `(space :align-to (- right (,hpos))) - `(space :align-to (,(- (frame-inner-width) hpos))))))) + `(space :align-to (,(- (frame-inner-width) + hpos))))))) `((align-right menu-item ,str ignore)))) (defun tab-bar-format-global () @@ -1018,7 +1026,7 @@ tab-bar-auto-width-max (const :tag "No limit" nil) (list (integer :tag "Max width (pixels)" :value 220) (integer :tag "Max width (chars)" :value 20))) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (setq tab-bar--fixed-width-hash nil)) @@ -1087,12 +1095,14 @@ tab-bar-auto-width curr-width) (cond ((< prev-width width) - (let* ((space (apply 'propertize " " + (let* ((space (apply #'propertize " " (text-properties-at 0 name))) (ins-pos (- len (if close-p 1 0))) (prev-name name)) (while continue - (setf (substring name ins-pos ins-pos) space) + (setq name (concat (substring name 0 ins-pos) + space + (substring name ins-pos))) (setq curr-width (string-pixel-width name)) (if (and (< curr-width width) (> curr-width prev-width)) @@ -1105,7 +1115,8 @@ tab-bar-auto-width (let ((del-pos1 (if close-p -2 -1)) (del-pos2 (if close-p -1 nil))) (while continue - (setf (substring name del-pos1 del-pos2) "") + (setq name (concat (substring name 0 del-pos1) + (substring name del-pos2))) (setq curr-width (string-pixel-width name)) (if (and (> curr-width width) (< curr-width prev-width)) @@ -1309,11 +1320,13 @@ tab-bar-select-tab (when tab-bar-history-mode (puthash (selected-frame) - (and (window-configuration-p (alist-get 'wc (car wc-history-back))) + (and (window-configuration-p + (alist-get 'wc (car wc-history-back))) wc-history-back) tab-bar-history-back) (puthash (selected-frame) - (and (window-configuration-p (alist-get 'wc (car wc-history-forward))) + (and (window-configuration-p + (alist-get 'wc (car wc-history-forward))) wc-history-forward) tab-bar-history-forward)))) @@ -1339,7 +1352,8 @@ tab-bar-select-tab (when from-index (setf (nth from-index tabs) from-tab)) - (setf (nth to-index tabs) (tab-bar--current-tab-make (nth to-index tabs))) + (setf (nth to-index tabs) + (tab-bar--current-tab-make (nth to-index tabs))) (unless tab-bar-mode (message "Selected tab '%s'" (alist-get 'name to-tab)))) @@ -1406,7 +1420,7 @@ tab-bar-switch-to-tab (tab-bar-new-tab) (tab-bar-rename-tab name)))) -(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab) +(defalias 'tab-bar-select-tab-by-name #'tab-bar-switch-to-tab) (defun tab-bar-move-tab-to (to-number &optional from-number) @@ -1421,7 +1435,8 @@ tab-bar-move-tab-to (from-number (or from-number (1+ (tab-bar--current-tab-index tabs)))) (from-tab (nth (1- from-number) tabs)) (to-number (if to-number (prefix-numeric-value to-number) 1)) - (to-number (if (< to-number 0) (+ (length tabs) (1+ to-number)) to-number)) + (to-number (if (< to-number 0) (+ (length tabs) (1+ to-number)) + to-number)) (to-index (max 0 (min (1- to-number) (1- (length tabs)))))) (setq tabs (delq from-tab tabs)) (cl-pushnew from-tab (nthcdr to-index tabs)) @@ -1447,7 +1462,8 @@ tab-bar-move-tab-backward (interactive "p") (tab-bar-move-tab (- (or arg 1)))) -(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-number to-frame to-number) +(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-number + to-frame to-number) "Move tab from FROM-NUMBER position to new position at TO-NUMBER. FROM-NUMBER defaults to the current tab number. FROM-NUMBER and TO-NUMBER count from 1. @@ -1463,7 +1479,8 @@ tab-bar-move-tab-to-frame (setq to-frame (next-frame to-frame)))) (unless (eq from-frame to-frame) (let* ((from-tabs (funcall tab-bar-tabs-function from-frame)) - (from-number (or from-number (1+ (tab-bar--current-tab-index from-tabs)))) + (from-number (or from-number + (1+ (tab-bar--current-tab-index from-tabs)))) (from-tab (nth (1- from-number) from-tabs)) (to-tabs (funcall tab-bar-tabs-function to-frame)) (to-index (max 0 (min (1- (or to-number 1)) (1- (length to-tabs)))))) @@ -1485,7 +1502,8 @@ tab-bar-detach-tab FROM-NUMBER defaults to the current tab (which happens interactively)." (interactive (list (1+ (tab-bar--current-tab-index)))) (let* ((tabs (funcall tab-bar-tabs-function)) - (tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs))))) + (tab-index (1- (or from-number + (1+ (tab-bar--current-tab-index tabs))))) (tab-name (alist-get 'name (nth tab-index tabs))) ;; On some window managers, `make-frame' selects the new frame, ;; so previously selected frame is saved to `from-frame'. @@ -1748,7 +1766,8 @@ tab-bar-close-tab ;; Select another tab before deleting the current tab (let ((to-index (or (if to-number (1- to-number)) (pcase tab-bar-close-tab-select - ('left (1- (if (< current-index 1) 2 current-index))) + ('left (1- (if (< current-index 1) 2 + current-index))) ('right (if (> (length tabs) (1+ current-index)) (1+ current-index) (1- current-index))) @@ -1773,7 +1792,8 @@ tab-bar-close-tab (force-mode-line-update) (unless tab-bar-mode - (message "Deleted tab and switched to %s" tab-bar-close-tab-select)))))) + (message "Deleted tab and switched to %s" + tab-bar-close-tab-select)))))) (defun tab-bar-close-tab-by-name (name) "Close the tab given its NAME. @@ -1864,7 +1884,8 @@ tab-bar-rename-tab function `tab-bar-tab-name-function'." (interactive (let* ((tabs (funcall tab-bar-tabs-function)) - (tab-number (or current-prefix-arg (1+ (tab-bar--current-tab-index tabs)))) + (tab-number (or current-prefix-arg + (1+ (tab-bar--current-tab-index tabs)))) (tab-name (alist-get 'name (nth (1- tab-number) tabs)))) (list (read-from-minibuffer "New name for tab (leave blank for automatic naming): " @@ -2129,10 +2150,10 @@ tab-bar-history-mode :version "29.1")) (setq tab-bar-forward-button (icon-string 'tab-bar-forward)) - (add-hook 'pre-command-hook 'tab-bar--history-pre-change) - (add-hook 'window-configuration-change-hook 'tab-bar--history-change)) - (remove-hook 'pre-command-hook 'tab-bar--history-pre-change) - (remove-hook 'window-configuration-change-hook 'tab-bar--history-change))) + (add-hook 'pre-command-hook #'tab-bar--history-pre-change) + (add-hook 'window-configuration-change-hook #'tab-bar--history-change)) + (remove-hook 'pre-command-hook #'tab-bar--history-pre-change) + (remove-hook 'window-configuration-change-hook #'tab-bar--history-change))) ;;; Non-graphical access to frame-local tabs (named window configurations) @@ -2172,8 +2193,9 @@ tab-switcher-noselect (tabs (sort tabs (lambda (a b) (< (alist-get 'time b) (alist-get 'time a)))))) (with-current-buffer (get-buffer-create - (format " *Tabs*<%s>" (or (frame-parameter nil 'window-id) - (frame-parameter nil 'name)))) + (format " *Tabs*<%s>" + (or (frame-parameter nil 'window-id) + (frame-parameter nil 'name)))) (setq buffer-read-only nil) (erase-buffer) (tab-switcher-mode) @@ -2188,7 +2210,8 @@ tab-switcher-noselect (propertize (alist-get 'name tab) 'mouse-face 'highlight - 'help-echo "mouse-2: select this window configuration")) + 'help-echo + "mouse-2: select this window configuration")) 'tab tab))) (goto-char (point-min)) (goto-char (or (next-single-property-change (point) 'tab) (point-min))) @@ -2264,8 +2287,8 @@ tab-switcher-prev-line (move-to-column tab-switcher-column)) (defun tab-switcher-unmark (&optional backup) - "Cancel requested operations on window configuration on this line and move down. -With prefix arg, move up instead." + "Cancel operations on window configuration on this line and move down. +With prefix arg BACKUP, move up instead." (interactive "P") (beginning-of-line) (move-to-column tab-switcher-column) @@ -2276,7 +2299,7 @@ tab-switcher-unmark (move-to-column tab-switcher-column)) (defun tab-switcher-backup-unmark () - "Move up one line and cancel requested operations on window configuration there." + "Move up one line and cancel operations on window configuration there." (interactive) (forward-line -1) (tab-switcher-unmark) @@ -2284,9 +2307,10 @@ tab-switcher-backup-unmark (move-to-column tab-switcher-column)) (defun tab-switcher-delete (&optional arg) - "Mark window configuration on this line to be deleted by \\\\[tab-switcher-execute] command. + "Mark window configuration on this line to be deleted. Prefix arg says how many window configurations to delete. -Negative arg means delete backwards." +Negative arg means delete backwards. +The deletion will be done by the \\\\[tab-switcher-execute] command." (interactive "p") (let ((buffer-read-only nil)) (if (or (null arg) (= arg 0)) @@ -2304,8 +2328,9 @@ tab-switcher-delete (move-to-column tab-switcher-column))) (defun tab-switcher-delete-backwards (&optional arg) - "Mark window configuration on this line to be deleted by \\\\[tab-switcher-execute] command. -Then move up one line. Prefix arg means move that many lines." + "Mark window configuration on this line to be deleted. +Then move up one line. Prefix arg means move that many lines. +The deletion will be done by the \\\\[tab-switcher-execute] command." (interactive "p") (tab-switcher-delete (- (or arg 1)))) @@ -2318,7 +2343,9 @@ tab-switcher-delete-from-list (tab-bar-tabs-set (delq tab (funcall tab-bar-tabs-function)))) (defun tab-switcher-execute () - "Delete window configurations marked with \\\\[tab-switcher-delete] commands." + "Delete the marked window configurations. +Use the \\\\[tab-switcher-delete] commands +to set those marks." (interactive) (save-excursion (goto-char (point-min)) @@ -2364,7 +2391,8 @@ tab-bar--reusable-frames ((framep all-frames) (list all-frames)) (t (list (selected-frame))))) -(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames ignore-current-tab all-tabs) +(defun tab-bar-get-buffer-tab (buffer-or-name + &optional all-frames ignore-current-tab all-tabs) "Return the tab that owns the window whose buffer is BUFFER-OR-NAME. BUFFER-OR-NAME may be a buffer or a buffer name, and defaults to the current buffer. @@ -2540,7 +2568,7 @@ find-file-other-tab (progn (setq value (nreverse value)) (switch-to-buffer-other-tab (car value)) - (mapc 'switch-to-buffer (cdr value)) + (mapc #'switch-to-buffer (cdr value)) value) (switch-to-buffer-other-tab value)))) @@ -2582,26 +2610,26 @@ other-tab-prefix ;;; Short aliases and keybindings -(defalias 'tab-new 'tab-bar-new-tab) -(defalias 'tab-new-to 'tab-bar-new-tab-to) -(defalias 'tab-duplicate 'tab-bar-duplicate-tab) -(defalias 'tab-detach 'tab-bar-detach-tab) -(defalias 'tab-window-detach 'tab-bar-move-window-to-tab) -(defalias 'tab-close 'tab-bar-close-tab) -(defalias 'tab-close-other 'tab-bar-close-other-tabs) -(defalias 'tab-close-group 'tab-bar-close-group-tabs) -(defalias 'tab-undo 'tab-bar-undo-close-tab) -(defalias 'tab-select 'tab-bar-select-tab) -(defalias 'tab-switch 'tab-bar-switch-to-tab) -(defalias 'tab-next 'tab-bar-switch-to-next-tab) -(defalias 'tab-previous 'tab-bar-switch-to-prev-tab) -(defalias 'tab-last 'tab-bar-switch-to-last-tab) -(defalias 'tab-recent 'tab-bar-switch-to-recent-tab) -(defalias 'tab-move 'tab-bar-move-tab) -(defalias 'tab-move-to 'tab-bar-move-tab-to) -(defalias 'tab-rename 'tab-bar-rename-tab) -(defalias 'tab-group 'tab-bar-change-tab-group) -(defalias 'tab-list 'tab-switcher) +(defalias 'tab-new #'tab-bar-new-tab) +(defalias 'tab-new-to #'tab-bar-new-tab-to) +(defalias 'tab-duplicate #'tab-bar-duplicate-tab) +(defalias 'tab-detach #'tab-bar-detach-tab) +(defalias 'tab-window-detach #'tab-bar-move-window-to-tab) +(defalias 'tab-close #'tab-bar-close-tab) +(defalias 'tab-close-other #'tab-bar-close-other-tabs) +(defalias 'tab-close-group #'tab-bar-close-group-tabs) +(defalias 'tab-undo #'tab-bar-undo-close-tab) +(defalias 'tab-select #'tab-bar-select-tab) +(defalias 'tab-switch #'tab-bar-switch-to-tab) +(defalias 'tab-next #'tab-bar-switch-to-next-tab) +(defalias 'tab-previous #'tab-bar-switch-to-prev-tab) +(defalias 'tab-last #'tab-bar-switch-to-last-tab) +(defalias 'tab-recent #'tab-bar-switch-to-recent-tab) +(defalias 'tab-move #'tab-bar-move-tab) +(defalias 'tab-move-to #'tab-bar-move-tab-to) +(defalias 'tab-rename #'tab-bar-rename-tab) +(defalias 'tab-group #'tab-bar-change-tab-group) +(defalias 'tab-list #'tab-switcher) (keymap-set tab-prefix-map "n" #'tab-duplicate) (keymap-set tab-prefix-map "N" #'tab-new-to)