2019-10-09 13:13:56 +02:00
|
|
|
;;; bookmark.el --- Saved files and directories on my filesystem -*- lexical-binding: t -*-
|
2020-09-01 11:17:43 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 11:17:43 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; Package-Requires: ((emacs "24.3"))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
2022-02-14 20:56:47 +01:00
|
|
|
;; A more opinionated version of Emacs's builtin `jump-to-register'.
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-01-27 17:21:30 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2022-02-14 22:46:16 +01:00
|
|
|
(require 'project)
|
2020-09-02 16:01:43 +02:00
|
|
|
(require 'general)
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2022-02-14 20:56:47 +01:00
|
|
|
;; Configuration
|
2019-10-09 13:13:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(cl-defstruct bookmark label path kbd)
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; API
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun bookmark-open (b)
|
2022-02-14 20:56:47 +01:00
|
|
|
"Open bookmark, B, as either a project directory or a regular directory."
|
|
|
|
(with-temp-buffer
|
2022-02-14 22:46:16 +01:00
|
|
|
(cd (bookmark-path b))
|
2022-02-14 20:56:47 +01:00
|
|
|
(call-interactively #'project-find-file)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2021-11-08 19:36:45 +01:00
|
|
|
(defun bookmark-install-kbd (b)
|
|
|
|
"Define two functions to explore B and assign them to keybindings."
|
|
|
|
(eval `(defun ,(intern (format "bookmark-visit-%s" (bookmark-label b))) ()
|
|
|
|
(interactive)
|
|
|
|
(find-file ,(bookmark-path b))))
|
|
|
|
(eval `(defun ,(intern (format "bookmark-browse-%s" (bookmark-label b))) ()
|
|
|
|
(interactive)
|
|
|
|
(bookmark-open ,b)))
|
|
|
|
(general-define-key
|
|
|
|
:prefix "<SPC>"
|
|
|
|
:states '(motion)
|
|
|
|
(format "J%s" (bookmark-kbd b)) `,(intern (format "bookmark-visit-%s" (bookmark-label b)))
|
|
|
|
(format "j%s" (bookmark-kbd b)) `,(intern (format "bookmark-browse-%s" (bookmark-label b)))))
|
2020-09-02 15:09:15 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(provide 'bookmark)
|
|
|
|
;;; bookmark.el ends here
|