Extract prelude-start-or-switch-to

This commit is contained in:
Bozhidar Batsov 2013-04-29 07:59:51 +03:00
parent b09eaf8e0e
commit 0a56b3ffb5

View file

@ -268,13 +268,16 @@ buffer is not visiting a file."
(file-writable-p buffer-file-name)) (file-writable-p buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun prelude-switch-or-start (function buffer) (defun prelude-start-or-switch-to (function buffer-name)
"If BUFFER is current, bury it, otherwise invoke FUNCTION." "Invoke FUNCTION if there is no buffer with BUFFER-NAME.
(if (equal (buffer-name (current-buffer)) buffer) Otherwise switch to the buffer named BUFFER-NAME. Don't clobber
(bury-buffer) the current buffer."
(if (get-buffer buffer) (if (not (get-buffer buffer-name))
(switch-to-buffer buffer) (progn
(funcall function)))) (split-window-sensibly (selected-window))
(other-window 1)
(funcall function))
(switch-to-buffer-other-window buffer-name)))
(defun prelude-insert-date () (defun prelude-insert-date ()
"Insert a timestamp according to locale's date and time format." "Insert a timestamp according to locale's date and time format."