aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-09-28 22:48:48 +0300
committerJuri Linkov2019-09-28 22:48:48 +0300
commitedf48d1d706219ab7cc0a9e267ad200ef82b9a4f (patch)
tree71009d2fc48a20b31ad23517e8c2dbb43ebf4235
parente47c389cfd446f6ac36a240fd11134ad2b91fb81 (diff)
downloademacs-edf48d1d706219ab7cc0a9e267ad200ef82b9a4f.tar.gz
emacs-edf48d1d706219ab7cc0a9e267ad200ef82b9a4f.zip
* lisp/tab-line.el: Add new defcustom tab-line-close-tab-action.
-rw-r--r--lisp/tab-line.el40
1 files changed, 32 insertions, 8 deletions
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index ee9ec023ffd..62e06a797d5 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -263,7 +263,10 @@ variable `tab-line-tabs-function'."
263 263
264 264
265(defun tab-line-new-tab (&optional e) 265(defun tab-line-new-tab (&optional e)
266 "Add a new tab." 266 "Add a new tab to the tab line.
267Usually is invoked by clicking on the plus-shaped button.
268But any switching to other buffer also adds a new tab
269corresponding to the switched buffer."
267 (interactive "e") 270 (interactive "e")
268 (if (functionp tab-line-new-tab-choice) 271 (if (functionp tab-line-new-tab-choice)
269 (funcall tab-line-new-tab-choice) 272 (funcall tab-line-new-tab-choice)
@@ -300,26 +303,47 @@ using the `previous-buffer' command."
300 (switch-to-buffer buffer)))))) 303 (switch-to-buffer buffer))))))
301 304
302(defun tab-line-switch-to-prev-tab (&optional e) 305(defun tab-line-switch-to-prev-tab (&optional e)
303 "Switch to the previous tab." 306 "Switch to the previous tab.
307Its effect is the same as using the `previous-buffer' command
308(\\[previous-buffer])."
304 (interactive "e") 309 (interactive "e")
305 (switch-to-prev-buffer (posn-window (event-start e)))) 310 (switch-to-prev-buffer (posn-window (event-start e))))
306 311
307(defun tab-line-switch-to-next-tab (&optional e) 312(defun tab-line-switch-to-next-tab (&optional e)
308 "Switch to the next tab." 313 "Switch to the next tab.
314Its effect is the same as using the `next-buffer' command
315(\\[next-buffer])."
309 (interactive "e") 316 (interactive "e")
310 (switch-to-next-buffer (posn-window (event-start e)))) 317 (switch-to-next-buffer (posn-window (event-start e))))
311 318
319(defcustom tab-line-close-tab-action 'bury-buffer
320 "Defines what to do on closing the tab.
321If `bury-buffer', put the tab's buffer at the end of the list of all
322buffers that effectively hides the buffer's tab from the tab line.
323If `kill-buffer', kills the tab's buffer."
324 :type '(choice (const :tag "Bury buffer" bury-buffer)
325 (const :tag "Kill buffer" kill-buffer))
326 :group 'tab-line
327 :version "27.1")
328
312(defun tab-line-close-tab (&optional e) 329(defun tab-line-close-tab (&optional e)
313 "Close the selected tab." 330 "Close the selected tab.
331Usually is invoked by clicking on the close button on the right side
332of the tab. This command buries the buffer, so it goes out of sight
333from the tab line."
314 (interactive "e") 334 (interactive "e")
315 (let* ((posnp (event-start e)) 335 (let* ((posnp (event-start e))
316 (window (posn-window posnp)) 336 (window (posn-window posnp))
317 (buffer (get-pos-property 1 'tab (car (posn-string posnp))))) 337 (buffer (get-pos-property 1 'tab (car (posn-string posnp)))))
318 (with-selected-window window 338 (with-selected-window window
319 (if (eq buffer (current-buffer)) 339 (cond
320 (bury-buffer) 340 ((eq tab-line-close-tab-action 'kill-buffer)
321 (set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers))) 341 (kill-buffer buffer))
322 (set-window-next-buffers nil (delq buffer (window-next-buffers)))) 342 ((eq tab-line-close-tab-action 'bury-buffer)
343 (if (eq buffer (current-buffer))
344 (bury-buffer)
345 (set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers)))
346 (set-window-next-buffers nil (delq buffer (window-next-buffers))))))
323 (force-mode-line-update)))) 347 (force-mode-line-update))))
324 348
325 349