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: Sun, 2 May 2021 20:13:58 -0400 Message-ID: <20210503001358.mjafsjlumdamrlvh@E15-2016.optimum.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="z5kmaqmaeiecnqzo" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39545"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 To: 48179@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 03 02:16:15 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 1ldMFy-000ACM-RM for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 May 2021 02:16:14 +0200 Original-Received: from localhost ([::1]:43752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldMFx-0002J7-QH for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 20:16:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldMEp-0001nS-90 for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 20:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldMEo-0001YY-5k for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 20:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldMEo-0000Rr-0R for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 20:15: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 00:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48179 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Reporting Original-Received: via spool by submit@debbugs.gnu.org id=B.16200008501695 (code B ref -1); Mon, 03 May 2021 00:15:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 May 2021 00:14:10 +0000 Original-Received: from localhost ([127.0.0.1]:45573 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldMDx-0000RH-Jt for submit@debbugs.gnu.org; Sun, 02 May 2021 20:14:09 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldMDu-0000RB-KV for submit@debbugs.gnu.org; Sun, 02 May 2021 20:14:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldMDu-0000og-8i for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 20:14:06 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:45267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldMDr-00010W-Ub for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 20:14:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620000841; bh=utDF5kQtQBPxDmr9qJLgtg0d2OexyWtUj8qcsC89278=; h=X-UI-Sender-Class:Date:From:To:Subject; b=SqogK3ZzbYwN3m05myn2wlAgYC4pQzpt8KvBo900O6McP0YvzJUNIB+dkoJxolNtF WFj18CzQa21wpmsmUiq5wWx+99XJEH1lXLxCOI//aioeag++/X+HJvptwWJUZN7JPj 2qhpqXwdi154K0hg6u9NTz3MCtyPDAhw90Ovolws= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([70.19.86.82]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MWici-1m5wlk2cKO-00X07x for ; Mon, 03 May 2021 02:14:00 +0200 Content-Disposition: inline X-Provags-ID: V03:K1:w5xBe/Rnpcs7J3ShtKtKLUKrj833YmKycwc642uwofkOz1xe9yh gvE/9ut4dFcauacmPUaRDAXpn7h3TPrsolYMSONDTjZg+kucvbMWLqGRmf2GC0zKzmvGaG3 TJ/+0nulMswLlDRqOOk2tmxxJ4rNpJnCtFvkzr9BI7Mgpsv7N9O1zAT8TLyWKZXZrcvYnBR WfkAQ7BaVZR2S44/RjpMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:WaC08JpFeag=:8quu3N5dkyhopI0FYD06oz +WtibAMFU8zt3Kb4zbfh2J0zUUD1xPeXZRjXTroZlkgoXNqLXOtGzRYS8CPfUbL1LvOoK4CC1 gp5KE86qzjq6i4SO6iNl3H1EYxl6KLP9c+M342I2qtjUnM6AXejNFy5RHIWzmREDKRvIqbkuP U9wSu61SLodDneRwYjY/UJGqkJ3BYqsBE8t6laRoNRVMOcv+VCUBZp9Xn+sLPH5Aya9otfFGr /d/YqjhojejP0G09czLSvpaZXedkp83Lz1EoQr6yhDTt778KYfWF8++PGnQnzWxeVbpLG1Lm9 UAgKTqFd67tINcth6RT4IqEFoFgVpkrc00elKFoIwVC5e4QNv6ODLBZxeRyspXCa8btpSyEEZ zBDo/qWqzVxzC9/faENZZtcKaaWZESIq7z9dsBsFnZJLnRtds7GFnAB/JntbVAezrUNA0VFiU 2O56XNFCaigbNBCaFlwVTF2SZeg93DHo5Y5WA3qFEnpuiwfneTe/8NLxKNzniIU+cxLU/Bsbb 3k1wTn+HrjH8fcJLhMaUb19d3lyu2qVrFupiaKDBoZJJRScSMtOjRo+Xmc7sRIYvzN33iwR0s XspzR4PyB1P669cmkinoykE/3RKwEHtsZuslIgPNzWqb1QW3L/oq+HL2N/2+sO1HSZUzJbGh8 wDC4IoODb/otju/HWSqGkBUlaMQ+36TC1I6v/nJHcs1Cis6LTfJzqsC7ezVV2XR71ZjRQjD9N zV21Oo8w6AT+cv60QgbvhfHLlW34S1kiHvHRL6WPd4+bzTelMXeDB4IuxtQEM2eD+zd0HyIC Received-SPF: pass client-ip=212.227.17.22; envelope-from=boruch_baum@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:205459 Archived-At: --z5kmaqmaeiecnqzo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The attached patch adds a feature to bookmark.el to colorize a bookmark's line, making it easily observable. The idea was adopted from package bm.el, available on MELPA. I was able to test this on Emacs 27, but there seem to have been some changes in snapshot to make it difficult to use that version of bookmark.el on my Emacs 27, so please verify that I performed the migration properly. OFF-TOPIC, but related: I've posted a pull-request to package bm.el adding to it a feature to make context-based suggestions for default bookmark annotations[1]. If Emacs wants that for package bookmark.el it should be possible to submit a parallel patch. [1] https://github.com/Boruch-Baum/emacs-bm/commit/dc1d8ad7eea64d94c345f3e= d3885eefd8ec72d65 =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0 --z5kmaqmaeiecnqzo Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bookmark-fontify.patch" Content-Transfer-Encoding: quoted-printable diff --git a/bookmark.el b/bookmark.el index 206c872..197678d 100644 =2D-- a/bookmark.el +++ b/bookmark.el @@ -165,11 +165,28 @@ 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") + (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. @@ -418,6 +435,31 @@ In other words, return all information but the name." "Set the rear-context-string of BOOKMARK-NAME-OR-RECORD to STRING." (bookmark-prop-set bookmark-name-or-record 'rear-context-string string)= ) +(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-get-handler (bookmark-name-or-record) "Return the handler function for BOOKMARK-NAME-OR-RECORD, or nil if non= e." @@ -824,7 +866,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))) @@ -1349,6 +1393,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 --z5kmaqmaeiecnqzo--