1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

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.
This commit is contained in:
Juri Linkov 2019-10-20 19:30:30 +03:00
parent cd4f707a98
commit dff8978f50
3 changed files with 33 additions and 15 deletions

View File

@ -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"

View File

@ -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))))

View File

@ -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