X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=elisp.git;a=blobdiff_plain;f=selector.el;h=419c96fdb53d427efef28501b2deabc7783cec5f;hp=17a5b2333f302fc31fa2a29189818766e1080d02;hb=a6876d786f18071b9abf0bfc56e6fc313e503e72;hpb=3771096a125c7cff7216ca61ce51b2cda5a7aca1 diff --git a/selector.el b/selector.el index 17a5b23..419c96f 100644 --- a/selector.el +++ b/selector.el @@ -63,6 +63,11 @@ Otherwise use the mode-line." :type 'bool :group 'selector) +(defcustom selector/add-to-file-name-history t + "If non-nil, file selected with selector/quick-pick-recent will be added to the mini-buffer filename history." + :type 'bool + :group 'selector) + (defcustom selector/mode-hook nil "Hook called at the end of the selector mode initialization." :type 'hook @@ -330,10 +335,12 @@ There seems to be header-line refreshing problems with emacs21." (if (file-remote-p s) " " (propertize - (format-time-string "%a %b %e" (elt (file-attributes s) 5)) + (format-time-string "%b %a %e" (elt (file-attributes s) 5)) 'face 'selector/date)) - " -- " + ;; " -- " + + " " (if (string-match abbreviated-home-dir s) (concat (propertize @@ -344,18 +351,28 @@ There seems to be header-line refreshing problems with emacs21." ) (defun selector/find-file (filename) + (if selector/add-to-file-name-history + (add-to-history 'file-name-history + (replace-regexp-in-string + abbreviated-home-dir "~/" filename) + ) + ) + + (find-file filename)) + +(defun selector/pick-file (filename) "Callback function for `selector/quick-pick-recent'. When called with a universal argument, allows the user to edit the filename." (interactive) (if current-prefix-arg - (find-file (read-file-name - "Find file: " - (file-name-directory filename) - nil - nil - (file-name-nondirectory filename))) - (find-file filename))) + (selector/find-file (read-file-name + "Find file: " + (file-name-directory filename) + nil + nil + (file-name-nondirectory filename))) + (selector/find-file filename))) (defun selector/quick-pick-recent () "Open a file picked in `recentf-list' with the dynamic @@ -373,7 +390,7 @@ prefix argument, allows to edit the filename after selection." (cons (selector/filename-to-string s) s)) recentf-list) - 'selector/find-file + 'selector/pick-file "*selector find-file*" ))