From: Boruch Baum <boruch_baum@gmx.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 48179@debbugs.gnu.org
Subject: bug#48179: bookmark-fontify [PATCH]
Date: Mon, 3 May 2021 05:58:28 -0400 [thread overview]
Message-ID: <20210503095828.66mcqkxyznb2vdja@E15-2016.optimum.net> (raw)
In-Reply-To: <87im40cgxz.fsf@gnus.org>
[-- Attachment #1: Type: text/plain, Size: 927 bytes --]
On 2021-05-03 11:19, Lars Ingebrigtsen wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
>
> > I thought I did base the patch on yesterday's gnu.org cgit version...
> > Here's what the on-line log is showing me...
> >
> > Age Commit message (Expand) Author Files Lines
> > 2020-09-07 Use format-prompt in read-file-name calls that Lars Ingebrigtsen 1 -3/+3
> > have a default
>
> There's been half a dozen commits to bookmark.el after that one, so I
> think your Emacs is out of date. The latest is
It's not *my* emacs. I only have access to debian emacs locally; the
data I gave you was from the URL I had for the on-line cgit repository
for emacs, at gnu.org. Here's a second patch, based upon hopefully the
most current URL, and with the additional jump code.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
[-- Attachment #2: bookmark-fontify-2.patch --]
[-- Type: text/x-diff, Size: 4154 bytes --]
diff --git a/bookmark.el b/bookmark.el
index 98797a0..af91a6e 100644
--- a/bookmark.el
+++ b/bookmark.el
@@ -167,12 +167,29 @@ A non-nil value may result in truncated bookmark names."
"Time before `bookmark-bmenu-search' updates the display."
:type 'number)
+(defcustom bookmark-fontify t
+ "Whether to colorize a bookmark's line.
+See face `bookmark-face'."
+ :type 'boolean
+ :version "27.2")
+
;; FIXME: No longer used. Should be declared obsolete or removed.
(defface bookmark-menu-heading
'((t (:inherit font-lock-type-face)))
"Face used to highlight the heading in bookmark menu buffers."
:version "22.1")
+(defface bookmark-face
+ '((((class grayscale)
+ (background light)) (:background "DimGray"))
+ (((class grayscale)
+ (background dark)) (:background "LightGray"))
+ (((class color)
+ (background light)) (:foreground "White" :background "DarkOrange1"))
+ (((class color)
+ (background dark)) (:foreground "Black" :background "DarkOrange1")))
+ "Face used to highlight current line."
+ :version "27.2")
;;; No user-serviceable parts beyond this point.
@@ -427,6 +444,31 @@ In other words, return all information but the name."
(defvar bookmark-history nil
"The history list for bookmark functions.")
+(defun bookmark--fontify ()
+ "Apply a colorized overlay to the bookmarked location.
+See defcustom variable `bookmark-fontify'."
+ (let ((bm (make-overlay (point-at-bol)
+ (min (point-max) (+ 1 (point-at-eol))))))
+ (overlay-put bm 'category 'bookmark)
+ (overlay-put bm 'face 'bookmark-face)))
+
+(defun bookmark--unfontify (bm)
+ "Remove a bookmark's colorized overlay.
+BM is a bookmark as returned from function `bookmark-get-bookmark'.
+See defcustom variable `bookmark-fontify'."
+ (let ((filename (assq 'filename bm))
+ (pos (assq 'position bm))
+ (buffers (buffer-list))
+ buf overlays found temp)
+ (when filename (setq filename (expand-file-name (cdr filename))))
+ (when pos (setq pos (cdr pos)))
+ (while (setq buf (pop buffers))
+ (with-current-buffer buf
+ (when (equal filename buffer-file-name)
+ (setq overlays (overlays-at pos))
+ (while (and (not found) (setq temp (pop overlays)))
+ (when (eq 'bookmark (overlay-get temp 'category))
+ (delete-overlay (setq found temp)))))))))
(defun bookmark-completing-read (prompt &optional default)
"Prompting with PROMPT, read a bookmark name in completion.
@@ -825,7 +867,9 @@ still there, in order, if the topmost one is ever deleted."
;; Ask for an annotation buffer for this bookmark
(when bookmark-use-annotations
- (bookmark-edit-annotation str))))
+ (bookmark-edit-annotation str))
+ (when bookmark-fontify
+ (bookmark--fontify))))
(setq bookmark-yank-point nil)
(setq bookmark-current-buffer nil)))
@@ -1094,6 +1138,14 @@ and then show any annotations for this bookmark."
(if win (set-window-point win (point))))
;; FIXME: we used to only run bookmark-after-jump-hook in
;; `bookmark-jump' itself, but in none of the other commands.
+ (when bookmark-fontify
+ (let ((overlays (overlays-at (point)))
+ temp found)
+ (while (and (not found) (setq temp (pop overlays)))
+ (when (eq 'bookmark (overlay-get temp 'category))
+ (setq found t)))
+ (unless found
+ (bookmark--fontify))))
(run-hooks 'bookmark-after-jump-hook)
(if bookmark-automatically-show-annotations
;; if there is an annotation for this bookmark,
@@ -1357,6 +1409,7 @@ probably because we were called from there."
(bookmark-maybe-historicize-string bookmark-name)
(bookmark-maybe-load-default-file)
(let ((will-go (bookmark-get-bookmark bookmark-name 'noerror)))
+ (bookmark--unfontify will-go)
(setq bookmark-alist (delq will-go bookmark-alist))
;; Added by db, nil bookmark-current-bookmark if the last
;; occurrence has been deleted
next prev parent reply other threads:[~2021-05-03 9:58 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-03 0:13 bug#48179: bookmark-fontify [PATCH] Boruch Baum
2021-05-03 0:40 ` bug#48179: [External] : " Drew Adams
2021-05-03 1:20 ` Boruch Baum
2021-05-03 1:25 ` Drew Adams
2021-05-04 0:35 ` Stefan Kangas
2021-05-04 16:37 ` bug#48179: [External] : " Drew Adams
2021-05-03 7:54 ` Lars Ingebrigtsen
2021-05-03 9:12 ` Boruch Baum
2021-05-03 9:19 ` Lars Ingebrigtsen
2021-05-03 9:58 ` Boruch Baum [this message]
2021-05-04 8:59 ` Lars Ingebrigtsen
2021-05-04 9:02 ` Lars Ingebrigtsen
2021-05-04 9:58 ` Basil L. Contovounesios
2021-05-05 8:13 ` Lars Ingebrigtsen
2021-05-05 12:26 ` Basil L. Contovounesios
2021-05-05 16:30 ` Boruch Baum
2021-05-06 8:57 ` Lars Ingebrigtsen
2021-05-06 10:31 ` Boruch Baum
2021-05-06 18:52 ` Basil L. Contovounesios
2021-05-06 18:52 ` Basil L. Contovounesios
2021-05-06 19:13 ` Boruch Baum
2021-05-06 19:41 ` Basil L. Contovounesios
2021-05-05 17:08 ` Boruch Baum
2021-05-06 8:58 ` Lars Ingebrigtsen
2021-05-06 10:38 ` Boruch Baum
2021-05-06 18:53 ` Basil L. Contovounesios
2021-05-06 11:03 ` Boruch Baum
2021-05-04 18:38 ` Boruch Baum
2021-05-05 8:15 ` Lars Ingebrigtsen
2021-05-05 10:48 ` Boruch Baum
2021-05-05 16:43 ` bug#48179: [External] : " Drew Adams
2021-05-06 8:53 ` Lars Ingebrigtsen
2021-05-05 15:39 ` Bastien
2021-05-05 17:25 ` Boruch Baum
2021-05-05 18:54 ` Eli Zaretskii
2021-05-06 8:54 ` Lars Ingebrigtsen
2021-05-06 9:57 ` Bastien
2021-05-06 10:12 ` Colin Baxter
2021-05-06 10:59 ` Boruch Baum
2021-05-06 8:49 ` Colin Baxter
2021-05-06 8:55 ` Lars Ingebrigtsen
2021-05-06 9:41 ` Colin Baxter
2021-05-06 10:24 ` Boruch Baum
2021-05-06 10:46 ` Colin Baxter
2021-05-06 10:52 ` Colin Baxter
2021-05-07 11:22 ` Lars Ingebrigtsen
2021-05-07 13:52 ` Colin Baxter
2021-05-07 16:22 ` bug#48179: [External] : " Drew Adams
2021-05-07 18:48 ` Colin Baxter
2021-05-08 0:25 ` Drew Adams
2021-06-06 0:27 ` bug#48179: bookmark-fontify disable by default Y. E.
2021-06-06 3:30 ` Pankaj Jangid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210503095828.66mcqkxyznb2vdja@E15-2016.optimum.net \
--to=boruch_baum@gmx.com \
--cc=48179@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).