From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#48179: bookmark-fontify [PATCH] Date: Mon, 3 May 2021 05:58:28 -0400 Message-ID: <20210503095828.66mcqkxyznb2vdja@E15-2016.optimum.net> References: <20210503001358.mjafsjlumdamrlvh@E15-2016.optimum.net> <87zgxcdzh3.fsf@gnus.org> <20210503091204.qhc2tda76wh6345w@E15-2016.optimum.net> <87im40cgxz.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="snits2kjt3ul7pwp" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14988"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 Cc: 48179@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 03 11:59:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldVM8-0003mW-F2 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 11:59:12 +0200 Original-Received: from localhost ([::1]:60572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldVM7-000557-Iz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 05:59:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldVLy-00054o-L6 for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 05:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldVLy-0007Yy-DV for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 05:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldVLy-00047F-DA for bug-gnu-emacs@gnu.org; Mon, 03 May 2021 05:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 May 2021 09:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48179 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 48179-submit@debbugs.gnu.org id=B48179.162003592115813 (code B ref 48179); Mon, 03 May 2021 09:59:02 +0000 Original-Received: (at 48179) by debbugs.gnu.org; 3 May 2021 09:58:41 +0000 Original-Received: from localhost ([127.0.0.1]:46256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldVLd-00046z-FL for submit@debbugs.gnu.org; Mon, 03 May 2021 05:58:41 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:40595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldVLZ-00046s-B9 for 48179@debbugs.gnu.org; Mon, 03 May 2021 05:58:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620035911; bh=T/Daon9qUKCTjMil80aoQ6cfHF/SKnXRmrKhJ+Fqrt8=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=YAw7b1nwl6NW/kqiKYGFQrsadCbnpgXWWVrcCvFz9t/ZHtfM7LujgLkUJjxaHkd8+ T5czT95hNwz3MqKGv043wMgzwyetqxbP77lv3aXJdUHlUneFlGyfaLeb2/7B3fINZO ahhtDvnNBz4chaCDDZ2X0tErRNYBckUlJQJpQZCg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([70.19.86.82]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N8XPt-1lYft12Xxp-014SVX; Mon, 03 May 2021 11:58:30 +0200 Content-Disposition: inline In-Reply-To: <87im40cgxz.fsf@gnus.org> X-Provags-ID: V03:K1:ojOIYfHXbUcrm7serwMpEvu4vZeLdL0szgzf0bc/KSGdPvXsSj8 TedY4oo7ArBmrs94e5VK9NfDvFwdsGdk3DylLFZwJYT/di0ecuCc4qbt9xL2Bphmuo9DTHp VFJIHzfQ7gF2D/IMLozuJ1WTcbxTDwsA+e3AfB41Y0HEQ7oEssG3p2ge+sdTjA1mxaPTEUJ dTXkMfLVGcVQf0XX+zLvw== X-UI-Out-Filterresults: notjunk:1;V03:K0:ysnIcLIp9js=:l9pdnzqoPmFWxiuzPiAaBb 9wkkh/Aq7bviJnHkJ0cnJV02cesCfaZyJyylj/SRKEVoRbRmPv0IIAyB9AS2UUwjV2wC8jwvU E5SJnZuj3XkcUNFQIjXv3WvN00kUkVGOyoKHrC7FQLH+KancjKJ6YEOspwyJClXDKGiHj2wSC sy0EbKxJsGkyPimZaRceaufgNKw9ywmKmH+UgRnmD66EyeaKIk0kaqa8HcqT7mqHTuw8K/67l ON8qC7p0GhveGax+8nSJKwrZiI4qb1oZFigDflT1NzoDaSgxNCcOsE+fipGx6sM5IN8M8SmhY y27wdUZ3FFgAaNKuUVH+XuDcs+zyE2xcaZDZttNgGAlfClyG9L62Qb0AFV3WHl7ovQEzpP7pO blHd8gq1/xSE3qydjEyTdsZb/I2RDvmRkw764wY03CX3gmTzOESSdrPixxRtcSxD5ay9soT5W q1Y3ixpTUQdxf2pB8ODk5jYAowGgAOw1qSN5kucdcDrTSpRmrwaP9MEi7w/4VfdapkR2b5/bn n71Gs6lYpKfdhwksLe+neMNZeE4F2+In2XrImhPR4zs333G5+309YLAbKEgsVynbiMXaUuBiS vleIbzyD9kPUpO2cf10TDW4X6sN/gZS4WAKcDH1rurH3j/qrxVt2LK9CpW/SYis3lIBsIyHGR 0BNK2muVauWrQDbd1CTVWKR3iEszMutjGwcniyiP+9zIP17uOsDeRkUWxN4QRpon4QusTyeaw VEQvEulRigE33BJQFyQO6ktclJgRLUsC+O6TLrs8Q4fk+fH72u/JlzxjxwgkhE3f6oF88qgS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205494 Archived-At: --snits2kjt3ul7pwp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-05-03 11:19, Lars Ingebrigtsen wrote: > Boruch Baum 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) Aut= hor Files Lines > > 2020-09-07 Use format-prompt in read-file-name calls that Lars Ing= ebrigtsen 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. =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0 --snits2kjt3ul7pwp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bookmark-fontify-2.patch" Content-Transfer-Encoding: quoted-printable diff --git a/bookmark.el b/bookmark.el index 98797a0..af91a6e 100644 =2D-- a/bookmark.el +++ b/bookmark.el @@ -167,12 +167,29 @@ A non-nil value may result in truncated bookmark nam= es." "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 dele= ted." ;; 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 --snits2kjt3ul7pwp--