diff options
| author | Juri Linkov | 2021-10-17 20:09:29 +0300 |
|---|---|---|
| committer | Juri Linkov | 2021-10-17 20:09:29 +0300 |
| commit | a191d3c725e155bd2d30c0c239cf68021cbd6c6d (patch) | |
| tree | 58316ac193469f06a2bf6ce3451976375db96831 | |
| parent | 77dbaedadc0129534e5ca9bdeef881a48b8d53e7 (diff) | |
| download | emacs-a191d3c725e155bd2d30c0c239cf68021cbd6c6d.tar.gz emacs-a191d3c725e155bd2d30c0c239cf68021cbd6c6d.zip | |
Add new and fix existing docstrings in tab-bar.el and tab-line.el (bug#51247)
* lisp/tab-bar.el (tab-bar--key-to-number)
(tab-bar--event-to-item, tab-bar--format-tab)
(tab-bar--format-tab-group, tab-bar--tab, tab-bar--current-tab)
(tab-bar--current-tab-make): Add/fix docstrings.
| -rw-r--r-- | lisp/tab-bar.el | 44 | ||||
| -rw-r--r-- | lisp/tab-line.el | 4 |
2 files changed, 34 insertions, 14 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 85f947f598c..8738e387b63 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -227,6 +227,10 @@ a list of frames to update." | |||
| 227 | ;;; Key bindings | 227 | ;;; Key bindings |
| 228 | 228 | ||
| 229 | (defun tab-bar--key-to-number (key) | 229 | (defun tab-bar--key-to-number (key) |
| 230 | "This function is used to interpret the key that represents a tab. | ||
| 231 | It returns `t' for the `nil' value, `nil' for the current tab, | ||
| 232 | returns the number for the symbol that begins with `tab-' like `tab-1', | ||
| 233 | and `t' for other values." | ||
| 230 | (cond | 234 | (cond |
| 231 | ((null key) t) | 235 | ((null key) t) |
| 232 | ((eq key 'current-tab) nil) | 236 | ((eq key 'current-tab) nil) |
| @@ -236,6 +240,10 @@ a list of frames to update." | |||
| 236 | (t t))) | 240 | (t t))) |
| 237 | 241 | ||
| 238 | (defun tab-bar--event-to-item (posn) | 242 | (defun tab-bar--event-to-item (posn) |
| 243 | "This function extracts extra info from the mouse event POSN. | ||
| 244 | It returns a list that contains three elements: a key, | ||
| 245 | a key binding, and a boolean value whether the close button \"+\" | ||
| 246 | was clicked." | ||
| 239 | (if (posn-window posn) | 247 | (if (posn-window posn) |
| 240 | (let ((caption (car (posn-string posn)))) | 248 | (let ((caption (car (posn-string posn)))) |
| 241 | (when caption | 249 | (when caption |
| @@ -741,7 +749,7 @@ You can hide these buttons by customizing `tab-bar-format' and removing | |||
| 741 | :help "Click to go forward in tab history")))) | 749 | :help "Click to go forward in tab history")))) |
| 742 | 750 | ||
| 743 | (defun tab-bar--format-tab (tab i) | 751 | (defun tab-bar--format-tab (tab i) |
| 744 | "Format TAB using its index I and return the result as a string." | 752 | "Format TAB using its index I and return the result as a keymap." |
| 745 | (append | 753 | (append |
| 746 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) | 754 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) |
| 747 | (cond | 755 | (cond |
| @@ -817,6 +825,9 @@ Function gets one argument: a tab." | |||
| 817 | (tab-bar-tab-face-default tab))) | 825 | (tab-bar-tab-face-default tab))) |
| 818 | 826 | ||
| 819 | (defun tab-bar--format-tab-group (tab i &optional current-p) | 827 | (defun tab-bar--format-tab-group (tab i &optional current-p) |
| 828 | "Format TAB as a tab that represents a group of tabs. | ||
| 829 | Use the argument I as its index, and non-nil CURRENT-P when the tab is | ||
| 830 | current. Return the result as a keymap." | ||
| 820 | (append | 831 | (append |
| 821 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) | 832 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) |
| 822 | `((,(intern (format "group-%i" i)) | 833 | `((,(intern (format "group-%i" i)) |
| @@ -927,6 +938,7 @@ on the tab bar instead." | |||
| 927 | (push '(tabs . frameset-filter-tabs) frameset-filter-alist) | 938 | (push '(tabs . frameset-filter-tabs) frameset-filter-alist) |
| 928 | 939 | ||
| 929 | (defun tab-bar--tab (&optional frame) | 940 | (defun tab-bar--tab (&optional frame) |
| 941 | "Make a new tab data structure that can be added to tabs on the FRAME." | ||
| 930 | (let* ((tab (tab-bar--current-tab-find nil frame)) | 942 | (let* ((tab (tab-bar--current-tab-find nil frame)) |
| 931 | (tab-explicit-name (alist-get 'explicit-name tab)) | 943 | (tab-explicit-name (alist-get 'explicit-name tab)) |
| 932 | (tab-group (alist-get 'group tab)) | 944 | (tab-group (alist-get 'group tab)) |
| @@ -961,12 +973,14 @@ on the tab bar instead." | |||
| 961 | (cdr tab))))) | 973 | (cdr tab))))) |
| 962 | 974 | ||
| 963 | (defun tab-bar--current-tab (&optional tab frame) | 975 | (defun tab-bar--current-tab (&optional tab frame) |
| 976 | "Make the current tab data structure from TAB on FRAME." | ||
| 964 | (tab-bar--current-tab-make (or tab (tab-bar--current-tab-find nil frame)))) | 977 | (tab-bar--current-tab-make (or tab (tab-bar--current-tab-find nil frame)))) |
| 965 | 978 | ||
| 966 | (defun tab-bar--current-tab-make (&optional tab) | 979 | (defun tab-bar--current-tab-make (&optional tab) |
| 967 | ;; `tab' here is an argument meaning "use tab as template". This is | 980 | "Make the current tab data structure from TAB. |
| 968 | ;; necessary when switching tabs, otherwise the destination tab | 981 | TAB here is an argument meaning \"use tab as template\". This is |
| 969 | ;; inherits the current tab's `explicit-name' parameter. | 982 | necessary when switching tabs, otherwise the destination tab |
| 983 | inherits the current tab's `explicit-name' parameter." | ||
| 970 | (let* ((tab-explicit-name (alist-get 'explicit-name tab)) | 984 | (let* ((tab-explicit-name (alist-get 'explicit-name tab)) |
| 971 | (tab-group (if tab | 985 | (tab-group (if tab |
| 972 | (alist-get 'group tab) | 986 | (alist-get 'group tab) |
| @@ -989,27 +1003,33 @@ on the tab bar instead." | |||
| 989 | (cdr tab))))) | 1003 | (cdr tab))))) |
| 990 | 1004 | ||
| 991 | (defun tab-bar--current-tab-find (&optional tabs frame) | 1005 | (defun tab-bar--current-tab-find (&optional tabs frame) |
| 1006 | ;; Find the current tab as a pointer to its data structure. | ||
| 992 | (assq 'current-tab (or tabs (funcall tab-bar-tabs-function frame)))) | 1007 | (assq 'current-tab (or tabs (funcall tab-bar-tabs-function frame)))) |
| 993 | 1008 | ||
| 994 | (defun tab-bar--current-tab-index (&optional tabs frame) | 1009 | (defun tab-bar--current-tab-index (&optional tabs frame) |
| 1010 | ;; Return the index of the current tab. | ||
| 995 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) | 1011 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) |
| 996 | 'current-tab (lambda (a b) (eq (car a) b)))) | 1012 | 'current-tab (lambda (a b) (eq (car a) b)))) |
| 997 | 1013 | ||
| 998 | (defun tab-bar--tab-index (tab &optional tabs frame) | 1014 | (defun tab-bar--tab-index (tab &optional tabs frame) |
| 1015 | ;; Return the index of TAB. | ||
| 999 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) | 1016 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) |
| 1000 | tab #'eq)) | 1017 | tab #'eq)) |
| 1001 | 1018 | ||
| 1002 | (defun tab-bar--tab-index-by-name (name &optional tabs frame) | 1019 | (defun tab-bar--tab-index-by-name (name &optional tabs frame) |
| 1020 | ;; Return the index of TAB by the its NAME. | ||
| 1003 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) | 1021 | (seq-position (or tabs (funcall tab-bar-tabs-function frame)) |
| 1004 | name (lambda (a b) (equal (alist-get 'name a) b)))) | 1022 | name (lambda (a b) (equal (alist-get 'name a) b)))) |
| 1005 | 1023 | ||
| 1006 | (defun tab-bar--tab-index-recent (nth &optional tabs frame) | 1024 | (defun tab-bar--tab-index-recent (nth &optional tabs frame) |
| 1025 | ;; Return the index of NTH recent tab. | ||
| 1007 | (let* ((tabs (or tabs (funcall tab-bar-tabs-function frame))) | 1026 | (let* ((tabs (or tabs (funcall tab-bar-tabs-function frame))) |
| 1008 | (sorted-tabs (tab-bar--tabs-recent tabs frame)) | 1027 | (sorted-tabs (tab-bar--tabs-recent tabs frame)) |
| 1009 | (tab (nth (1- nth) sorted-tabs))) | 1028 | (tab (nth (1- nth) sorted-tabs))) |
| 1010 | (tab-bar--tab-index tab tabs))) | 1029 | (tab-bar--tab-index tab tabs))) |
| 1011 | 1030 | ||
| 1012 | (defun tab-bar--tabs-recent (&optional tabs frame) | 1031 | (defun tab-bar--tabs-recent (&optional tabs frame) |
| 1032 | ;; Return the list of tabs sorted by recency. | ||
| 1013 | (let* ((tabs (or tabs (funcall tab-bar-tabs-function frame)))) | 1033 | (let* ((tabs (or tabs (funcall tab-bar-tabs-function frame)))) |
| 1014 | (seq-sort-by (lambda (tab) (alist-get 'time tab)) #'> | 1034 | (seq-sort-by (lambda (tab) (alist-get 'time tab)) #'> |
| 1015 | (seq-remove (lambda (tab) | 1035 | (seq-remove (lambda (tab) |
| @@ -1227,7 +1247,7 @@ to which to move the tab; ARG defaults to 1." | |||
| 1227 | 1247 | ||
| 1228 | (defun tab-bar-detach-tab (&optional from-number) | 1248 | (defun tab-bar-detach-tab (&optional from-number) |
| 1229 | "Move tab number FROM-NUMBER to a new frame. | 1249 | "Move tab number FROM-NUMBER to a new frame. |
| 1230 | FROM-NUMBER defaults to the current tab (which happens interactively." | 1250 | FROM-NUMBER defaults to the current tab (which happens interactively)." |
| 1231 | (interactive (list (1+ (tab-bar--current-tab-index)))) | 1251 | (interactive (list (1+ (tab-bar--current-tab-index)))) |
| 1232 | (let* ((tabs (funcall tab-bar-tabs-function)) | 1252 | (let* ((tabs (funcall tab-bar-tabs-function)) |
| 1233 | (tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs))))) | 1253 | (tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs))))) |
| @@ -1260,11 +1280,11 @@ If `left', create to the left of the current tab. | |||
| 1260 | If `right', create to the right of the current tab. | 1280 | If `right', create to the right of the current tab. |
| 1261 | If `rightmost', create as the last tab. | 1281 | If `rightmost', create as the last tab. |
| 1262 | If the value is a function, it should return a number as a position | 1282 | If the value is a function, it should return a number as a position |
| 1263 | on the tab bar specifying where to insert a new tab." | 1283 | on the tab bar specifying where to add a new tab." |
| 1264 | :type '(choice (const :tag "Insert first" leftmost) | 1284 | :type '(choice (const :tag "Add as First" leftmost) |
| 1265 | (const :tag "Insert left" left) | 1285 | (const :tag "Add to Left" left) |
| 1266 | (const :tag "Insert right" right) | 1286 | (const :tag "Add to Right" right) |
| 1267 | (const :tag "Insert last" rightmost) | 1287 | (const :tag "Add as Last" rightmost) |
| 1268 | (function :tag "Function")) | 1288 | (function :tag "Function")) |
| 1269 | :group 'tab-bar | 1289 | :group 'tab-bar |
| 1270 | :version "27.1") | 1290 | :version "27.1") |
| @@ -1632,7 +1652,7 @@ function `tab-bar-tab-name-function'." | |||
| 1632 | ;;; Tab groups | 1652 | ;;; Tab groups |
| 1633 | 1653 | ||
| 1634 | (defun tab-bar-move-tab-to-group (&optional tab) | 1654 | (defun tab-bar-move-tab-to-group (&optional tab) |
| 1635 | "Relocate TAB (default: the current tab) closer to its group." | 1655 | "Relocate TAB (by default, the current tab) closer to its group." |
| 1636 | (interactive) | 1656 | (interactive) |
| 1637 | (let* ((tabs (funcall tab-bar-tabs-function)) | 1657 | (let* ((tabs (funcall tab-bar-tabs-function)) |
| 1638 | (tab (or tab (tab-bar--current-tab-find tabs))) | 1658 | (tab (or tab (tab-bar--current-tab-find tabs))) |
| @@ -2021,7 +2041,7 @@ Then move up one line. Prefix arg means move that many lines." | |||
| 2021 | (tab-switcher-delete (- (or arg 1)))) | 2041 | (tab-switcher-delete (- (or arg 1)))) |
| 2022 | 2042 | ||
| 2023 | (defun tab-switcher-delete-from-list (tab) | 2043 | (defun tab-switcher-delete-from-list (tab) |
| 2024 | "Delete the window configuration from both lists." | 2044 | "Delete the window configuration from the list of tabs." |
| 2025 | (push `((frame . ,(selected-frame)) | 2045 | (push `((frame . ,(selected-frame)) |
| 2026 | (index . ,(tab-bar--tab-index tab)) | 2046 | (index . ,(tab-bar--tab-index tab)) |
| 2027 | (tab . ,tab)) | 2047 | (tab . ,tab)) |
diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 5be9052af4b..5affae79138 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el | |||
| @@ -269,7 +269,7 @@ the list of all tabs." | |||
| 269 | tab-line-tab-name-buffer) | 269 | tab-line-tab-name-buffer) |
| 270 | (const :tag "Truncated buffer name" | 270 | (const :tag "Truncated buffer name" |
| 271 | tab-line-tab-name-truncated-buffer) | 271 | tab-line-tab-name-truncated-buffer) |
| 272 | (function :tag "Function")) | 272 | (function :tag "Function")) |
| 273 | :initialize 'custom-initialize-default | 273 | :initialize 'custom-initialize-default |
| 274 | :set (lambda (sym val) | 274 | :set (lambda (sym val) |
| 275 | (set-default sym val) | 275 | (set-default sym val) |
| @@ -543,7 +543,7 @@ This is used by `tab-line-format'." | |||
| 543 | 543 | ||
| 544 | (defun tab-line-tab-face-inactive-alternating (tab tabs face _buffer-p selected-p) | 544 | (defun tab-line-tab-face-inactive-alternating (tab tabs face _buffer-p selected-p) |
| 545 | "Return FACE for TAB in TABS with alternation. | 545 | "Return FACE for TAB in TABS with alternation. |
| 546 | SELECTED-P non-nil means TAB is not the selected tab. | 546 | SELECTED-P nil means TAB is not the selected tab. |
| 547 | When TAB is not selected and is even-numbered, make FACE | 547 | When TAB is not selected and is even-numbered, make FACE |
| 548 | inherit from `tab-line-tab-inactive-alternate'. For use in | 548 | inherit from `tab-line-tab-inactive-alternate'. For use in |
| 549 | `tab-line-tab-face-functions'." | 549 | `tab-line-tab-face-functions'." |