Function: org-ctags-visit-buffer-or-file
org-ctags-visit-buffer-or-file is an interactive and byte-compiled
function defined in org-ctags.el.gz.
Signature
(org-ctags-visit-buffer-or-file NAME &optional CREATE)
Documentation
This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
Visit buffer named NAME.org. If there is no such buffer, visit the file
with the same name if it exists. If the file does not exist, then behavior
depends on the value of CREATE.
If CREATE is nil (default), then return nil. Do not create a new file.
If CREATE is t, create the new file and visit it.
If CREATE is the symbol ask, then ask the user if they wish to create
the new file.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-ctags.el.gz
(defun org-ctags-visit-buffer-or-file (name &optional create)
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
Visit buffer named `NAME.org'. If there is no such buffer, visit the file
with the same name if it exists. If the file does not exist, then behavior
depends on the value of CREATE.
If CREATE is nil (default), then return nil. Do not create a new file.
If CREATE is t, create the new file and visit it.
If CREATE is the symbol `ask', then ask the user if they wish to create
the new file."
(interactive)
(let ((filename (concat (substitute-in-file-name
(expand-file-name name))
".org")))
(cond
((get-buffer (concat name ".org"))
;; Buffer is already open
(pop-to-buffer-same-window (get-buffer (concat name ".org"))))
((file-exists-p filename)
;; File exists but is not open --> open it
(message "Opening existing org file `%S'..."
filename)
(org-open-file filename t))
((or (eql create t)
(and (eql create 'ask)
(y-or-n-p (format-message
"File `%s.org' not found; create?" name))))
(org-ctags-open-file filename name))
(t ;; File does not exist, and we don't want to create it.
nil))))