Commit 338360e4 authored by Yasushi SHOJI's avatar Yasushi SHOJI Committed by Jason Blevins

Extract widget at the point to filename

Extract a code fragment which gets the file name from the widget at the
current point, and name it `deft-filename-at-point`.
parent 26b04dbd
......@@ -1322,11 +1322,16 @@ non-nil and title is not from filename, use it as the title."
(setq slug (deft-unused-slug)))
(deft-new-file-named slug)))
(defun deft-filename-at-point ()
"Return the file name represented by the widget at the point,
or nil, If the point is not on a file widget."
(widget-get (widget-at) :tag))
(defun deft-open-file-other-window (&optional arg)
"When the point is at a widget, open the file in the other window.
The argument ARG is passed to `deft-open-file'."
(interactive "P")
(let ((file (widget-get (widget-at) :tag)))
(let ((file (deft-filename-at-point)))
(when file
(deft-open-file file t arg))))
......@@ -1335,7 +1340,7 @@ The argument ARG is passed to `deft-open-file'."
If the point is not on a file widget, do nothing. Prompts before
proceeding."
(interactive)
(let ((filename (widget-get (widget-at) :tag)))
(let ((filename (deft-filename-at-point)))
(when filename
(when (y-or-n-p
(concat "Delete file " (file-name-nondirectory filename) "? "))
......@@ -1348,7 +1353,7 @@ proceeding."
"Rename the file represented by the widget at the point.
If the point is not on a file widget, do nothing."
(interactive)
(let ((old-filename (widget-get (widget-at) :tag))
(let ((old-filename (deft-filename-at-point))
(deft-dir (file-name-as-directory deft-directory))
new-filename old-name new-name)
(when old-filename
......@@ -1367,7 +1372,7 @@ If the point is not on a file widget, do nothing."
If the point is not on a file widget, do nothing."
(interactive)
(let (old new name-ext)
(setq old (widget-get (widget-at) :tag))
(setq old (deft-filename-at-point))
(when old
(setq name-ext (file-name-nondirectory old))
(setq new (concat deft-archive-directory name-ext))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment