Add the bookmark cube
This commit is contained in:
parent
6eaed01362
commit
5af9e1543b
|
@ -38,6 +38,7 @@
|
|||
(require 'cubes/snippets)
|
||||
(require 'cubes/org)
|
||||
(require 'cubes/git)
|
||||
(require 'cubes/bookmark)
|
||||
|
||||
;; ============== MY STUFF ==============================
|
||||
(custom-set-faces
|
||||
|
@ -129,6 +130,7 @@
|
|||
|
||||
(fg42/vterm-cube)
|
||||
(fg42/git-cube)
|
||||
(fg42/bookmark-cube)
|
||||
(fg42/java-cube)
|
||||
(fg42/yasnippet-cube)
|
||||
;; Themes should be the last cube and anything that wants to manipulate a face
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
;;; Bookmark --- Bookmarks within the code -*- lexical-binding: t; -*-
|
||||
;;
|
||||
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
|
||||
;;
|
||||
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||
;; URL: https://gitlab.com/FG42/FG42
|
||||
;; Version: 3.0.0
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with thnis program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;; Commentary:
|
||||
;; Cubes are the building blocks of any `FG42' editor. Each `cube' is a
|
||||
;; unit which defines different abilities in a deterministic and idempotent
|
||||
;; way. Cubes are composable and a composition of cubes creates an editor.
|
||||
;;
|
||||
;;; Code:
|
||||
(require 'fpkg)
|
||||
(require 'fg42/cube)
|
||||
|
||||
|
||||
(defcube fg42/bookmark-cube
|
||||
(:docs "cubes/fg42/bookmark-cube.org"
|
||||
:flag bookmark
|
||||
:flag-default t)
|
||||
|
||||
(let* ((bnext (or (plist-get fg42/bookmark-cube-params :bm-next-key) "M-]"))
|
||||
(bprev (or (plist-get fg42/bookmark-cube-params :bm-previous-key) "M-["))
|
||||
(btoggle (or (plist-get fg42/bookmark-cube-params :bm-toggel-key) "M-p"))
|
||||
(keys `(list (,bnext . bm-next)
|
||||
(,bprev . bm-previous)
|
||||
(,btoggle . bm-toggle))))
|
||||
(eval
|
||||
`(fpkg/use bm
|
||||
:init
|
||||
;; restore on load (even before you require bm)
|
||||
(setq bm-restore-repository-on-load t)
|
||||
|
||||
|
||||
|
||||
:config
|
||||
;; Allow cross-buffer 'next'
|
||||
(setq bm-cycle-all-buffers t)
|
||||
|
||||
;; where to store persistant files
|
||||
(setq bm-repository-file (expand-file-name "bm-repository" user-emacs-directory))
|
||||
|
||||
;; save bookmarks
|
||||
(setq-default bm-buffer-persistence t)
|
||||
|
||||
;; Loading the repository from file when on start up.
|
||||
(add-hook 'after-init-hook 'bm-repository-load)
|
||||
|
||||
;; Saving bookmarks
|
||||
(add-hook 'kill-buffer-hook #'bm-buffer-save)
|
||||
|
||||
;; Saving the repository to file when on exit.
|
||||
;; kill-buffer-hook is not called when Emacs is killed, so we
|
||||
;; must save all bookmarks first.
|
||||
(add-hook 'kill-emacs-hook #'(lambda nil
|
||||
(bm-buffer-save-all)
|
||||
(bm-repository-save)))
|
||||
|
||||
;; The `after-save-hook' is not necessary to use to achieve persistence,
|
||||
;; but it makes the bookmark data in repository more in sync with the file
|
||||
;; state.
|
||||
(add-hook 'after-save-hook #'bm-buffer-save)
|
||||
|
||||
;; Restoring bookmarks
|
||||
(add-hook 'find-file-hooks #'bm-buffer-restore)
|
||||
(add-hook 'after-revert-hook #'bm-buffer-restore)
|
||||
|
||||
;; The `after-revert-hook' is not necessary to use to achieve persistence,
|
||||
;; but it makes the bookmark data in repository more in sync with the file
|
||||
;; state. This hook might cause trouble when using packages
|
||||
;; that automatically reverts the buffer (like vc after a check-in).
|
||||
;; This can easily be avoided if the package provides a hook that is
|
||||
;; called before the buffer is reverted (like `vc-before-checkin-hook').
|
||||
;; Then new bookmarks can be saved before the buffer is reverted.
|
||||
;; Make sure bookmarks is saved before check-in (and revert-buffer)
|
||||
(add-hook 'vc-before-checkin-hook #'bm-buffer-save)
|
||||
|
||||
|
||||
:bind ((,bnext . bm-next)
|
||||
(,bprev . bm-previous)
|
||||
(,btoggle . bm-toggle))))))
|
||||
|
||||
(provide 'cubes/bookmark)
|
||||
;;; bookmark.el ends here
|
Loading…
Reference in New Issue