diff options
| author | Juri Linkov | 2019-10-20 19:30:30 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-10-20 19:30:30 +0300 |
| commit | dff8978f5004561e2625b4199cefd8c262bb42cb (patch) | |
| tree | 30ce829dae65e462bb5f04ebb7585d85b6da148b | |
| parent | cd4f707a987e954ef4ff1edb2639e4cb5c57bb59 (diff) | |
| download | emacs-dff8978f5004561e2625b4199cefd8c262bb42cb.tar.gz emacs-dff8978f5004561e2625b4199cefd8c262bb42cb.zip | |
Provide default value for tab-name/frame-name reading minibuffer
* lisp/tab-bar.el (tab-bar-rename-tab, tab-bar-rename-tab-by-name):
Provide default value for read-string.
(tab-bar-select-tab-by-name): Alias for tab-bar-switch-to-tab.
* lisp/frame.el (set-frame-name): Provide default value for
read-string in interactive spec.
* lisp/cus-start.el (tab-bar-position): Use choice instead of boolean.
| -rw-r--r-- | lisp/cus-start.el | 16 | ||||
| -rw-r--r-- | lisp/frame.el | 4 | ||||
| -rw-r--r-- | lisp/tab-bar.el | 28 |
3 files changed, 33 insertions, 15 deletions
diff --git a/lisp/cus-start.el b/lisp/cus-start.el index d1278192ef7..e4b6d8f2d62 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el | |||
| @@ -591,12 +591,16 @@ since it could result in memory overflow and make Emacs crash." | |||
| 591 | (const :tag "Text-image-horiz" :value text-image-horiz) | 591 | (const :tag "Text-image-horiz" :value text-image-horiz) |
| 592 | (const :tag "System default" :value nil)) "24.1") | 592 | (const :tag "System default" :value nil)) "24.1") |
| 593 | (tool-bar-max-label-size frames integer "24.1") | 593 | (tool-bar-max-label-size frames integer "24.1") |
| 594 | (tab-bar-position tab-bar boolean "27.1" | 594 | (tab-bar-position |
| 595 | :set (lambda (sym val) | 595 | tab-bar (choice |
| 596 | (set-default sym val) | 596 | (const :tag "Tab bar above tool bar" nil) |
| 597 | ;; Redraw the bars: | 597 | (const :tag "Tab bar below tool bar" t)) |
| 598 | (tab-bar-mode -1) | 598 | "27.1" |
| 599 | (tab-bar-mode 1))) | 599 | :set (lambda (sym val) |
| 600 | (set-default sym val) | ||
| 601 | ;; Redraw the bars: | ||
| 602 | (tab-bar-mode -1) | ||
| 603 | (tab-bar-mode 1))) | ||
| 600 | (auto-hscroll-mode scrolling | 604 | (auto-hscroll-mode scrolling |
| 601 | (choice | 605 | (choice |
| 602 | (const :tag "Don't scroll automatically" | 606 | (const :tag "Don't scroll automatically" |
diff --git a/lisp/frame.el b/lisp/frame.el index 018c2f578e4..92fe57fbe63 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -1548,7 +1548,9 @@ often have their own features for raising or lowering frames." | |||
| 1548 | When called interactively, prompt for the name of the frame. | 1548 | When called interactively, prompt for the name of the frame. |
| 1549 | On text terminals, the frame name is displayed on the mode line. | 1549 | On text terminals, the frame name is displayed on the mode line. |
| 1550 | On graphical displays, it is displayed on the frame's title bar." | 1550 | On graphical displays, it is displayed on the frame's title bar." |
| 1551 | (interactive "sFrame name: ") | 1551 | (interactive |
| 1552 | (list (read-string "Frame name: " nil nil | ||
| 1553 | (cdr (assq 'name (frame-parameters)))))) | ||
| 1552 | (modify-frame-parameters (selected-frame) | 1554 | (modify-frame-parameters (selected-frame) |
| 1553 | (list (cons 'name name)))) | 1555 | (list (cons 'name name)))) |
| 1554 | 1556 | ||
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 800b65091a0..117b8ea9d01 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -541,6 +541,8 @@ to the numeric argument. ARG counts from 1." | |||
| 541 | (funcall tab-bar-tabs-function))))) | 541 | (funcall tab-bar-tabs-function))))) |
| 542 | (tab-bar-select-tab (1+ (tab-bar--tab-index-by-name name)))) | 542 | (tab-bar-select-tab (1+ (tab-bar--tab-index-by-name name)))) |
| 543 | 543 | ||
| 544 | (defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab) | ||
| 545 | |||
| 544 | 546 | ||
| 545 | (defcustom tab-bar-new-tab-to 'right | 547 | (defcustom tab-bar-new-tab-to 'right |
| 546 | "Defines where to create a new tab. | 548 | "Defines where to create a new tab. |
| @@ -669,13 +671,20 @@ TO-INDEX counts from 1." | |||
| 669 | (force-mode-line-update) | 671 | (force-mode-line-update) |
| 670 | (message "Deleted all other tabs"))))) | 672 | (message "Deleted all other tabs"))))) |
| 671 | 673 | ||
| 674 | |||
| 672 | (defun tab-bar-rename-tab (name &optional arg) | 675 | (defun tab-bar-rename-tab (name &optional arg) |
| 673 | "Rename the tab specified by its absolute position ARG. | 676 | "Rename the tab specified by its absolute position ARG. |
| 674 | If no ARG is specified, then rename the current tab. | 677 | If no ARG is specified, then rename the current tab. |
| 675 | ARG counts from 1. | 678 | ARG counts from 1. |
| 676 | If NAME is the empty string, then use the automatic name | 679 | If NAME is the empty string, then use the automatic name |
| 677 | function `tab-bar-tab-name-function'." | 680 | function `tab-bar-tab-name-function'." |
| 678 | (interactive "sNew name for tab (leave blank for automatic naming): \nP") | 681 | (interactive |
| 682 | (let* ((tabs (funcall tab-bar-tabs-function)) | ||
| 683 | (tab-index (or current-prefix-arg (1+ (tab-bar--current-tab-index tabs)))) | ||
| 684 | (tab-name (cdr (assq 'name (nth (1- tab-index) tabs))))) | ||
| 685 | (list (read-string "New name for tab (leave blank for automatic naming): " | ||
| 686 | nil nil tab-name) | ||
| 687 | current-prefix-arg))) | ||
| 679 | (let* ((tabs (funcall tab-bar-tabs-function)) | 688 | (let* ((tabs (funcall tab-bar-tabs-function)) |
| 680 | (tab-index (if arg | 689 | (tab-index (if arg |
| 681 | (1- (max 0 (min arg (length tabs)))) | 690 | (1- (max 0 (min arg (length tabs)))) |
| @@ -687,7 +696,7 @@ function `tab-bar-tab-name-function'." | |||
| 687 | (funcall tab-bar-tab-name-function)))) | 696 | (funcall tab-bar-tab-name-function)))) |
| 688 | (setf (cdr (assq 'name tab-to-rename)) tab-new-name | 697 | (setf (cdr (assq 'name tab-to-rename)) tab-new-name |
| 689 | (cdr (assq 'explicit-name tab-to-rename)) tab-explicit-name) | 698 | (cdr (assq 'explicit-name tab-to-rename)) tab-explicit-name) |
| 690 | (if (tab-bar-mode) | 699 | (if tab-bar-mode |
| 691 | (force-mode-line-update) | 700 | (force-mode-line-update) |
| 692 | (message "Renamed tab to '%s'" tab-new-name)))) | 701 | (message "Renamed tab to '%s'" tab-new-name)))) |
| 693 | 702 | ||
| @@ -695,12 +704,15 @@ function `tab-bar-tab-name-function'." | |||
| 695 | "Rename the tab named TAB-NAME. | 704 | "Rename the tab named TAB-NAME. |
| 696 | If NEW-NAME is the empty string, then use the automatic name | 705 | If NEW-NAME is the empty string, then use the automatic name |
| 697 | function `tab-bar-tab-name-function'." | 706 | function `tab-bar-tab-name-function'." |
| 698 | (interactive (list (completing-read "Rename tab by name: " | 707 | (interactive |
| 699 | (mapcar (lambda (tab) | 708 | (let ((tab-name (completing-read "Rename tab by name: " |
| 700 | (cdr (assq 'name tab))) | 709 | (mapcar (lambda (tab) |
| 701 | (funcall tab-bar-tabs-function))) | 710 | (cdr (assq 'name tab))) |
| 702 | (read-from-minibuffer "New name for tab (leave blank for automatic naming): "))) | 711 | (funcall tab-bar-tabs-function))))) |
| 703 | (tab-bar-rename-tab new-name (tab-bar--tab-index-by-name tab-name))) | 712 | (list tab-name |
| 713 | (read-string "New name for tab (leave blank for automatic naming): " | ||
| 714 | nil nil tab-name)))) | ||
| 715 | (tab-bar-rename-tab new-name (1+ (tab-bar--tab-index-by-name tab-name)))) | ||
| 704 | 716 | ||
| 705 | 717 | ||
| 706 | ;;; Short aliases | 718 | ;;; Short aliases |