Browse Source

Simplify how we find parents in MPDel browser mode

single-buffer
jao 1 year ago
parent
commit
2b1a3ed427
1 changed files with 3 additions and 25 deletions
  1. +3
    -25
      mpdel-browser.el

+ 3
- 25
mpdel-browser.el View File

@ -257,42 +257,20 @@ existing browser buffer, if any, instead of creating it."
(mpdel-browser-mode))
(navigel-method mpdel navigel-entity-id ((dir libmpdel-directory))
(let ((name (libmpdel--directory-name dir)))
(if (member name '("." ".."))
(libmpdel--directory-path dir)
name)))
(libmpdel--directory-path dir))
(navigel-method mpdel navigel-entity-tablist-mode ((_e (eql stored-playlists)))
(mpdel-browser-mode))
(defun mpdel-browser--entry-is-parent-directory-p (entity)
"Check whether the given ENTITY is a parent directory."
(let ((name (when (libmpdel-directory-p entity)
(libmpdel-entity-name entity))))
;; Browser buffers showing children of 'directories or the point
;; to their parent via a tablist entry called "Music directory",
;; while real directory children use the conventional "..".
(or (eql 'directories entity)
(eql 'browser entity)
(string= ".." name)
(string= "Music directory" name))))
(defun mpdel-browser--find-parent-directory ()
"Find the parent directory of current buffer, or 'browser if none."
(or (car (cl-find-if #'mpdel-browser--entry-is-parent-directory-p
tabulated-list-entries
:key #'car-safe))
'browser))
(cl-defmethod navigel-parent-to-open ((album libmpdel-album))
"Find the parent of the given ALBUM."
(if (string-empty-p (or (libmpdel-artist-name album) ""))
(list 'albums album)
(list (libmpdel--album-artist album) album)))
(cons (libmpdel--album-artist album) album)))
(cl-defmethod navigel-parent-to-open (_e &context (major-mode mpdel-browser-mode))
"Find parent of ENTITY when in a buffer with MAJOR-MODE `mpdel-browser-mode'."
(list (mpdel-browser--find-parent-directory)))
(list (or (navigel-parent navigel-entity) 'browser)))
(cl-defmethod navigel-parent-to-open
(_e &context (major-mode mpdel-playlist-current-playlist-mode))


Loading…
Cancel
Save