From 0a3085ae36165d651ad671ed5f3857cf3117cb1c Mon Sep 17 00:00:00 2001 From: lycheejelly Date: Tue, 11 Feb 2025 10:08:09 -0800 Subject: [PATCH] use emacs-lisp syntax highlighting in code blocks --- README.md | 187 +++++++++++++++++++++++++++--------------------------- 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index b2d1981..8e861ec 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,16 @@ Installation: ------------- To use bm.el, put it in your load-path and add the following to your .emacs - - (require 'bm) - +```emacs-lisp +(require 'bm) +``` or - (autoload 'bm-toggle "bm" "Toggle bookmark in current buffer." t) - (autoload 'bm-next "bm" "Goto bookmark." t) - (autoload 'bm-previous "bm" "Goto previous bookmark." t) - +```emacs-lisp +(autoload 'bm-toggle "bm" "Toggle bookmark in current buffer." t) +(autoload 'bm-next "bm" "Goto bookmark." t) +(autoload 'bm-previous "bm" "Goto previous bookmark." t) +``` Configuration: -------------- @@ -56,104 +57,104 @@ Configuration: To make it easier to use, assign the commands to some keys. M$ Visual Studio key setup. - - (global-set-key (kbd "") 'bm-toggle) - (global-set-key (kbd "") 'bm-next) - (global-set-key (kbd "") 'bm-previous) - +```emacs-lisp +(global-set-key (kbd "") 'bm-toggle) +(global-set-key (kbd "") 'bm-next) +(global-set-key (kbd "") 'bm-previous) +``` Click on fringe to toggle bookmarks, and use mouse wheel to move between them. - - (global-set-key (kbd " ") 'bm-next-mouse) - (global-set-key (kbd " ") 'bm-previous-mouse) - (global-set-key (kbd " ") 'bm-toggle-mouse) - +```emacs-lisp +(global-set-key (kbd " ") 'bm-next-mouse) +(global-set-key (kbd " ") 'bm-previous-mouse) +(global-set-key (kbd " ") 'bm-toggle-mouse) +``` If you would like the markers on the right fringe instead of the left, add the following line: - - (setq bm-marker 'bm-marker-right) - +```emacs-lisp +(setq bm-marker 'bm-marker-right) +``` If you would like to cycle bookmark in LIFO order, add the following line: - - (setq bm-in-lifo-order t) - +```emacs-lisp +(setq bm-in-lifo-order t) +``` If you would like to cycle through bookmarks in *all* open buffers, add the following line: - - (setq bm-cycle-all-buffers t) - +```emacs-lisp +(setq bm-cycle-all-buffers t) +``` If you would like to remove bookmark after jump to it by `bm-next` or `bm-previous`: - - (setq temporary-bookmark-p t) - +```emacs-lisp +(setq temporary-bookmark-p t) +``` or if you want use this feature in your library: - - (bm-bookmark-add nil nil t) - +```emacs-lisp +(bm-bookmark-add nil nil t) +``` If you need org-mode to expand the region containing a bookmark, add the following: - - (add-hook 'bm-after-goto-hook 'org-bookmark-jump-unhide) - +```emacs-lisp +(add-hook 'bm-after-goto-hook 'org-bookmark-jump-unhide) +``` Configuring bm.el with use-package: --------------------------------- Configuring bm.el with [use-package](https://github.com/jwiegley/use-package) - - (use-package bm - :ensure t - :demand t - - :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 "~/.emacs.d/bm-repository") - - ;; 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 (("" . bm-next) - ("S-" . bm-previous) - ("C-" . bm-toggle)) - ) - +```emacs-lisp +(use-package bm + :ensure t + :demand t + + :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 "~/.emacs.d/bm-repository") + + ;; 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 (("" . bm-next) + ("S-" . bm-previous) + ("C-" . bm-toggle)) + ) +``` Reviews and comments: