From 85242cd785a90f9927f77444e0d1ddede8629424 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 13 Sep 2024 05:17:00 -0700 Subject: [PATCH] Add my/bookmark-find-file --- .gitignore | 1 + init.el | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 7775240..ab67048 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /tree-sitter/ /tramp /dape-breakpoints +flycheck_init.el diff --git a/init.el b/init.el index bffd780..637ed07 100644 --- a/init.el +++ b/init.el @@ -229,6 +229,26 @@ Interactively, force the recompile if called with a prefix." :config (recentf-mode 1)) +;; bookmarks +(use-package bookmark + :ensure nil + :bind ("C-c b" . my/bookmark-find-file) + :config + (defun my/bookmark-find-file (&optional name) + "Run `find-file' in or on bookmark NAME. +If NAME points to a directory, run `find-file' with `default-directory' in that +directory. Otherwise, run `find-file' on that file." + (interactive (list (bookmark-completing-read + "Find file in" bookmark-current-bookmark))) + (unless name + (error "No bookmark specified")) + (bookmark-maybe-historicize-string name) + (when-let ((file (bookmark-get-filename name))) + (if (file-directory-p file) + (let ((default-directory (file-name-as-directory file))) + (call-interactively 'find-file)) + (find-file file))))) + ;; kitty keyboard protocol (use-package kkp :config