mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-30 16:07:59 +01:00
Fix exwm-workspace-rename-buffer
Ensure buffer names are unique.
This commit is contained in:
parent
b50a6e6dd9
commit
bb4ebde55b
1 changed files with 11 additions and 10 deletions
|
@ -202,16 +202,17 @@ The optional FORCE option is for internal use only."
|
||||||
|
|
||||||
(defun exwm-workspace-rename-buffer (newname)
|
(defun exwm-workspace-rename-buffer (newname)
|
||||||
"Rename a buffer."
|
"Rename a buffer."
|
||||||
(if (/= ?\s (aref newname 0))
|
(let ((hidden (= ?\s (aref newname 0)))
|
||||||
(rename-buffer newname t)
|
(basename (replace-regexp-in-string "<[0-9]+>$" "" newname))
|
||||||
;; If a buffer name is prefixed with a space, Emacs append a random
|
(counter 1)
|
||||||
;; number before renaming it. This is not desired behavior.
|
tmp)
|
||||||
(let ((name (replace-regexp-in-string "<[0-9]+>$" "" newname))
|
(when hidden (setq basename (substring basename 1)))
|
||||||
(counter 1))
|
(setq newname basename)
|
||||||
(while (and (get-buffer newname)
|
(while (and (setq tmp (or (get-buffer newname)
|
||||||
(not (eq (get-buffer newname) (current-buffer))))
|
(get-buffer (concat " " newname))))
|
||||||
(setq newname (format "%s<%d>" name (cl-incf counter)))))
|
(not (eq tmp (current-buffer))))
|
||||||
(rename-buffer newname)))
|
(setq newname (format "%s<%d>" basename (cl-incf counter))))
|
||||||
|
(rename-buffer (concat (and hidden " ") newname))))
|
||||||
|
|
||||||
(defun exwm-workspace--init ()
|
(defun exwm-workspace--init ()
|
||||||
"Initialize workspace module."
|
"Initialize workspace module."
|
||||||
|
|
Loading…
Reference in a new issue