Add desktop-registry-current-desktop
* desktop-registry.el (desktop-registry--canonicalize-dir): (desktop-registry-current-desktop): New functions. (desktop-registry-add-directory): Use `desktop-registry--canonicalize-dir' to get the "clean" directory name.
This commit is contained in:
parent
131cd421c0
commit
395277047e
3 changed files with 31 additions and 1 deletions
3
NEWS
3
NEWS
|
@ -5,3 +5,6 @@
|
||||||
|
|
||||||
- Add =desktop-registry-remove-desktop= command to remove desktops you
|
- Add =desktop-registry-remove-desktop= command to remove desktops you
|
||||||
no longer (want to) use.
|
no longer (want to) use.
|
||||||
|
|
||||||
|
- Add =desktop-registry-current-desktop= function to get the name of
|
||||||
|
the currently loaded desktop.
|
||||||
|
|
11
README.org
11
README.org
|
@ -27,3 +27,14 @@ to fix that.
|
||||||
|
|
||||||
When you're done with a desktop or want to get rid of a desktop for
|
When you're done with a desktop or want to get rid of a desktop for
|
||||||
another reason you can use =desktop-registry-remove-desktop=.
|
another reason you can use =desktop-registry-remove-desktop=.
|
||||||
|
|
||||||
|
** With org-capture-templates
|
||||||
|
|
||||||
|
The =desktop-registry-current-desktop= can be used to insert the
|
||||||
|
currently loaded desktop into an org capture template.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(add-to-list 'org-capture-templates
|
||||||
|
'("t" "Task" entry nil
|
||||||
|
"* TODO %? :%(desktop-registry-current-desktop):"))
|
||||||
|
#+END_SRC
|
||||||
|
|
|
@ -44,11 +44,27 @@
|
||||||
(defvar desktop-registry--history nil
|
(defvar desktop-registry--history nil
|
||||||
"History variable for `desktop-registry'.")
|
"History variable for `desktop-registry'.")
|
||||||
|
|
||||||
|
(defun desktop-registry--canonicalize-dir (dir)
|
||||||
|
"Canonicalize DIR for use."
|
||||||
|
(directory-file-name (expand-file-name dir)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun desktop-registry-current-desktop ()
|
||||||
|
"Get the name of the currently loaded desktop.
|
||||||
|
|
||||||
|
Returns an empty string when `desktop-dirname' is nil."
|
||||||
|
(if desktop-dirname
|
||||||
|
(let ((canonical
|
||||||
|
(desktop-registry--canonicalize-dir desktop-dirname)))
|
||||||
|
(car (cl-find-if (lambda (d) (equal (cdr d) canonical))
|
||||||
|
desktop-registry-registry)))
|
||||||
|
""))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun desktop-registry-add-directory (dir)
|
(defun desktop-registry-add-directory (dir)
|
||||||
"Add DIR to the desktop registry."
|
"Add DIR to the desktop registry."
|
||||||
(interactive "DDirectory: ")
|
(interactive "DDirectory: ")
|
||||||
(let* ((clean-dir (directory-file-name (expand-file-name dir)))
|
(let* ((clean-dir (desktop-registry--canonicalize-dir dir))
|
||||||
(label (file-name-base clean-dir)))
|
(label (file-name-base clean-dir)))
|
||||||
(unless (assoc label desktop-registry-registry)
|
(unless (assoc label desktop-registry-registry)
|
||||||
(customize-save-variable
|
(customize-save-variable
|
||||||
|
|
Loading…
Reference in a new issue