Skip to content

Commit

Permalink
Add crux-recentf-find-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolden authored and bbatsov committed Feb 24, 2021
1 parent 273390e commit a471cbe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [#65](https://github.com/bbatsov/crux/pull/65): Add a configuration option to move using visual lines in `crux-move-to-mode-line-start`.
* [#72](https://github.com/bbatsov/crux/pull/72): Add `crux-kill-buffer-truename`. Kills path of file visited by current buffer.
* [#78](https://github.com/bbatsov/crux/pull/78): Add `crux-recentf-find-directory`. Open recently visited directory.

### Bugs fixed

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Command | Suggested Keybinding(s)
`crux-smart-open-line` | <kbd>S-RET</kbd> or <kbd>M-o</kbd> | Insert an empty line and indent it properly (as in most IDEs).
`crux-cleanup-buffer-or-region` | <kbd>C-c n</kbd> | Fix indentation in buffer and strip whitespace.
`crux-recentf-find-file` | <kbd>C-c f</kbd> or <kbd>Super-r</kbd> | Open recently visited file.
`crux-recentf-find-directory` | <kbd>C-c F</kbd> | Open recently visited directory.
`crux-view-url` | <kbd>C-c u</kbd> | Open a new buffer containing the contents of URL.
`crux-eval-and-replace` | <kbd>C-c e</kbd> | Eval a bit of Emacs Lisp code and replace it with its result.
`crux-transpose-windows` | <kbd>C-x 4 t</kbd> | Transpose the buffers between two windows.
Expand Down
19 changes: 14 additions & 5 deletions crux.el
Original file line number Diff line number Diff line change
Expand Up @@ -606,17 +606,26 @@ as the current user."
(insert (format-time-string "%c" (current-time))))

;;;###autoload
(defun crux-recentf-find-file ()
"Find a recent file using `completing-read'."
(defun crux-recentf-find-file (&optional filter)
"Find a recent file using `completing-read'.
When optional argument FILTER is a function, it is used to
transform recent files before completion."
(interactive)
(let ((file (completing-read "Choose recent file: "
(mapcar #'abbreviate-file-name recentf-list)
nil t)))
(let* ((filter (if (functionp filter) filter #'abbreviate-file-name))
(file (completing-read "Choose recent file: "
(delete-dups (mapcar filter recentf-list))
nil t)))
(when file
(find-file file))))

(define-obsolete-function-alias 'crux-recentf-ido-find-file 'crux-recentf-find-file "0.4.0")

;;;###autoload
(defun crux-recentf-find-directory ()
"Find a recent directory using `completing-read'."
(interactive)
(crux-recentf-find-file (lambda (file) (abbreviate-file-name (file-name-directory file)))))

;; modified from https://www.emacswiki.org/emacs/TransposeWindows
;;;###autoload
(defun crux-transpose-windows (arg)
Expand Down

0 comments on commit a471cbe

Please sign in to comment.