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