diff options
author | Damien Elmes <emms@repose.cx> | 2006-06-16 13:19:00 +0000 |
---|---|---|
committer | Damien Elmes <emms@repose.cx> | 2006-06-16 13:19:00 +0000 |
commit | 73810bc2e36ee74b2dae29bbbde5f1fd9c99d970 (patch) | |
tree | 72bf0ca6b09f9a6230d0302cf8869772c9d96a30 | |
parent | 6ce6dd88e208a36baa641ec5c5c06b849353b944 (diff) |
browser: remember position when hitting 1,2,3 etc
darcs-hash:20060616131926-4e3e3-48d11c2d5b27bd26c8ed5ccf4e96f2c0480cf1da.gz
-rw-r--r-- | emms-browser.el | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/emms-browser.el b/emms-browser.el index c8ee617..3056ea4 100644 --- a/emms-browser.el +++ b/emms-browser.el @@ -783,38 +783,75 @@ LEVEL is used to control indentation." (defun emms-browser-expand-to-level-2 () "Expand all top level items one level." (interactive) - (emms-browser-collapse-all) + (emms-browser-mark-and-collapse) (emms-browser-expand-to-level 2)) (defun emms-browser-expand-to-level-3 () "Expand all top level items two levels." (interactive) - (emms-browser-collapse-all) + (emms-browser-mark-and-collapse) (emms-browser-expand-to-level 3)) (defun emms-browser-expand-to-level-4 () "Expand all top level items three levels." (interactive) - (emms-browser-collapse-all) + (emms-browser-mark-and-collapse) (emms-browser-expand-to-level 4)) (defun emms-browser-expand-to-level (level) - "Expand to an a depth specified by LEVEL." + "Expand to a depth specified by LEVEL. +After expanding, jump to the currently marked entry." (goto-char (point-min)) (while (not (eq (buffer-end 1) (point))) (if (< (emms-browser-level-at-point) level) (emms-browser-show-subitems)) (emms-browser-next-non-track)) - (goto-char (point-min))) + (emms-browser-pop-mark) + (recenter '(4))) (defun emms-browser-collapse-all () - "Collapse everything." + "Collapse everything, saving and restoring the mark." (interactive) + (emms-browser-mark-and-collapse) + (emms-browser-pop-mark) + (recenter '(4))) + +(defun emms-browser-mark-and-collapse () + "Save the current top level element, and collapse." + (emms-browser-mark-entry) (goto-char (point-max)) (while (not (eq (buffer-end -1) (point))) (emms-browser-prev-non-track) (emms-browser-kill-subitems))) +(defun emms-browser-find-top-level () + "Move up until reaching a top-level element." + (while (not (eq (emms-browser-level-at-point) 1)) + (forward-line -1))) + +(defun emms-browser-mark-entry () + "Mark the current top level entry." + (save-excursion + (emms-browser-find-top-level) + (emms-with-inhibit-read-only-t + (add-text-properties (line-beginning-position) + (line-end-position) + (list 'emms-browser-mark t))))) + +(defun emms-browser-pop-mark () + "Return to the last marked entry, and remove the mark." + (goto-char (point-min)) + (let ((pos (text-property-any (point-min) (point-max) + 'emms-browser-mark t))) + (if pos + (progn + (goto-char pos) + (emms-with-inhibit-read-only-t + (remove-text-properties (line-beginning-position) + (line-end-position) + (list 'emms-browser-mark)))) + (message "No mark saved!")))) + ;; -------------------------------------------------- ;; Linked browser and playlist windows ;; -------------------------------------------------- |