[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master dff8978: Provide default value for tab-name/frame-n
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] master dff8978: Provide default value for tab-name/frame-name reading minibuffer |
Date: |
Sun, 20 Oct 2019 12:30:37 -0400 (EDT) |
branch: master
commit dff8978f5004561e2625b4199cefd8c262bb42cb
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>
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.
---
lisp/cus-start.el | 16 ++++++++++------
lisp/frame.el | 4 +++-
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 d127819..e4b6d8f 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."
(const :tag "Text-image-horiz" :value text-image-horiz)
(const :tag "System default" :value nil)) "24.1")
(tool-bar-max-label-size frames integer "24.1")
- (tab-bar-position tab-bar boolean "27.1"
- :set (lambda (sym val)
- (set-default sym val)
- ;; Redraw the bars:
- (tab-bar-mode -1)
- (tab-bar-mode 1)))
+ (tab-bar-position
+ tab-bar (choice
+ (const :tag "Tab bar above tool bar" nil)
+ (const :tag "Tab bar below tool bar" t))
+ "27.1"
+ :set (lambda (sym val)
+ (set-default sym val)
+ ;; Redraw the bars:
+ (tab-bar-mode -1)
+ (tab-bar-mode 1)))
(auto-hscroll-mode scrolling
(choice
(const :tag "Don't scroll automatically"
diff --git a/lisp/frame.el b/lisp/frame.el
index 018c2f5..92fe57f 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1548,7 +1548,9 @@ often have their own features for raising or lowering
frames."
When called interactively, prompt for the name of the frame.
On text terminals, the frame name is displayed on the mode line.
On graphical displays, it is displayed on the frame's title bar."
- (interactive "sFrame name: ")
+ (interactive
+ (list (read-string "Frame name: " nil nil
+ (cdr (assq 'name (frame-parameters))))))
(modify-frame-parameters (selected-frame)
(list (cons 'name name))))
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 800b650..117b8ea 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -541,6 +541,8 @@ to the numeric argument. ARG counts from 1."
(funcall
tab-bar-tabs-function)))))
(tab-bar-select-tab (1+ (tab-bar--tab-index-by-name name))))
+(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab)
+
(defcustom tab-bar-new-tab-to 'right
"Defines where to create a new tab.
@@ -669,13 +671,20 @@ TO-INDEX counts from 1."
(force-mode-line-update)
(message "Deleted all other tabs")))))
+
(defun tab-bar-rename-tab (name &optional arg)
"Rename the tab specified by its absolute position ARG.
If no ARG is specified, then rename the current tab.
ARG counts from 1.
If NAME is the empty string, then use the automatic name
function `tab-bar-tab-name-function'."
- (interactive "sNew name for tab (leave blank for automatic naming): \nP")
+ (interactive
+ (let* ((tabs (funcall tab-bar-tabs-function))
+ (tab-index (or current-prefix-arg (1+ (tab-bar--current-tab-index
tabs))))
+ (tab-name (cdr (assq 'name (nth (1- tab-index) tabs)))))
+ (list (read-string "New name for tab (leave blank for automatic naming): "
+ nil nil tab-name)
+ current-prefix-arg)))
(let* ((tabs (funcall tab-bar-tabs-function))
(tab-index (if arg
(1- (max 0 (min arg (length tabs))))
@@ -687,7 +696,7 @@ function `tab-bar-tab-name-function'."
(funcall tab-bar-tab-name-function))))
(setf (cdr (assq 'name tab-to-rename)) tab-new-name
(cdr (assq 'explicit-name tab-to-rename)) tab-explicit-name)
- (if (tab-bar-mode)
+ (if tab-bar-mode
(force-mode-line-update)
(message "Renamed tab to '%s'" tab-new-name))))
@@ -695,12 +704,15 @@ function `tab-bar-tab-name-function'."
"Rename the tab named TAB-NAME.
If NEW-NAME is the empty string, then use the automatic name
function `tab-bar-tab-name-function'."
- (interactive (list (completing-read "Rename tab by name: "
- (mapcar (lambda (tab)
- (cdr (assq 'name tab)))
- (funcall tab-bar-tabs-function)))
- (read-from-minibuffer "New name for tab (leave blank for
automatic naming): ")))
- (tab-bar-rename-tab new-name (tab-bar--tab-index-by-name tab-name)))
+ (interactive
+ (let ((tab-name (completing-read "Rename tab by name: "
+ (mapcar (lambda (tab)
+ (cdr (assq 'name tab)))
+ (funcall tab-bar-tabs-function)))))
+ (list tab-name
+ (read-string "New name for tab (leave blank for automatic naming): "
+ nil nil tab-name))))
+ (tab-bar-rename-tab new-name (1+ (tab-bar--tab-index-by-name tab-name))))
;;; Short aliases
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master dff8978: Provide default value for tab-name/frame-name reading minibuffer,
Juri Linkov <=