From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#20845: 25.0.50; bookmark.el, handling of fictitious `buffer' property Date: Fri, 5 Jul 2019 10:16:18 -0700 (PDT) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="129681"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 20845@debbugs.gnu.org To: Stefan Kangas , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 05 19:19:31 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hjRrv-000Xav-Ew for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Jul 2019 19:19:31 +0200 Original-Received: from localhost ([::1]:55010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjRpk-00065h-WF for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Jul 2019 13:17:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55449) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjRpX-00065K-Pb for bug-gnu-emacs@gnu.org; Fri, 05 Jul 2019 13:17:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hjRpW-0002fj-H8 for bug-gnu-emacs@gnu.org; Fri, 05 Jul 2019 13:17:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hjRpW-0002fL-CJ for bug-gnu-emacs@gnu.org; Fri, 05 Jul 2019 13:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hjRpW-000106-3n for bug-gnu-emacs@gnu.org; Fri, 05 Jul 2019 13:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Jul 2019 17:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20845 X-GNU-PR-Package: emacs Original-Received: via spool by 20845-submit@debbugs.gnu.org id=B20845.15623469963804 (code B ref 20845); Fri, 05 Jul 2019 17:17:02 +0000 Original-Received: (at 20845) by debbugs.gnu.org; 5 Jul 2019 17:16:36 +0000 Original-Received: from localhost ([127.0.0.1]:53660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hjRp5-0000zH-2j for submit@debbugs.gnu.org; Fri, 05 Jul 2019 13:16:36 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:60578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hjRp1-0000yw-Pu for 20845@debbugs.gnu.org; Fri, 05 Jul 2019 13:16:32 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x65HEZda173949; Fri, 5 Jul 2019 17:16:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=j6ofeEU1N1iCRSndF1D8EHJ4Yd3GgN51rtfIs/cAQAg=; b=3DHsi5K8lyfqKd46hETkVTmjsfRlHKqgaexxJYyCoy5dQbg1dPs5BajRpXgqHVe2W2a2 hV7v8pzRByiVHiRbmuvPKFv/XwPBuKuhp8eHAkL/iF8BG1IyWrBba7X0iBC74G7ZbqnL jx8CJpP7v7nCi99gPPvYjfM9f2NVCS43ToRxa7ouv1cZSEhrBiOf8ao12bZI1Ct2kC1g DOl3l+0htVyg3uaFyZIgZRil7knAwanC/hP/LjyTQ9Yv9p9ImmnOo842UWJwHdVYTWnw 7E+z2izPz6QbPc6uqixw9uDUDLF02Nx7zquc7bBqBcO0/dC6BhdkrqP+R5xno8KPcspC VA== Original-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2te61qbxg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 17:16:24 +0000 Original-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x65HCebr099506; Fri, 5 Jul 2019 17:16:24 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2th9echnjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 17:16:23 +0000 Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x65HGJds009436; Fri, 5 Jul 2019 17:16:21 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4861.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9309 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050212 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9309 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050213 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162139 Archived-At: > > > I'm looking into Emacs Bug#20845 which asks about the purpose of the > > > "bookmark" property in bookmark.el. > > > > I don't see any `bookmark` property, sorry. >=20 > That should be "buffer", sorry about that. That typo at the beginning of the report was my fault. I meant `buffer' property, not `bookmark' property. > > Oh, I see how/where it's used and it's definitely still used: > > Info-bookmark-jump uses it (i.e. not in the stored bookmark object, but > > in a transient object passed to bookmark-default-handler). Yes, thanks for pointing that out. > > So maybe it should be documented in the docstring of > > `bookmark-default-handler` for the benefit of other handlers. >=20 > I agree with this conclusion. So not only do we keep it, but we document > it. >=20 > Thanks for helping out Stefan, it seems we now have a way forward. I agree, provided the doc of `bookmark-default-handler' makes clear (1) that the value is assumed to be a buffer, not a buffer name, and (2) that this is not a "normal" bookmark property, that is, one whose value can be saved. It's OK for a jump function to pass a buffer object as the property value to the default handler. But it's generally not OK for code to try to store a buffer value for property `buffer'. Such a bookmark works OK in a live `bookmark-alist', but it isn't persistable. That the default handler recognizes this property, which cannot be persisted, is a bit aberrant. It's normal for mode-setting, narrowing, etc. to be coded in a jump function. What's not so normal is to communicate the buffer to the default bookmark handler as a bookmark property. It should be sufficient to communicate the buffer _name_ as the property value. And that's something savable and retrievable - it's useful generally. IOW, it's OK to have `buffer' bookmark property, but I think its value should be a buffer name. Something like this might be better than what we have now (tested only mildly, using vanilla Emacs 26.2): (defun Info-bookmark-make-record () "" (let* ((file (and (stringp Info-current-file) (file-name-sans-extension (file-name-nondirectory Info-current-file)))) (bookmark-name (if file (concat "(" file ") " Info-current-node) Info-current-node)) (defaults (delq nil (list bookmark-name file Info-current-node)))) `(,bookmark-name ,@(bookmark-make-record-default 'no-file) (filename . ,Info-current-file) (info-node . ,Info-current-node) (buffer . ,(buffer-name)) ; <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (handler . Info-bookmark-jump) (defaults . ,defaults)))) (defun Info-bookmark-jump (bmk) "" (let* ((file (bookmark-prop-get bmk 'filename)) (node (bookmark-prop-get bmk 'info-node))) (Info-find-node file node) ;; Use `bookmark-default-handler' to move to location in node. (bookmark-default-handler (cons "" (bookmark-get-bookmark-record bmk))))) <=3D=3D=3D=3D=3D no BU= F (defun bookmark-default-handler (bmk-record) "" (let ((file (bookmark-get-filename bmk-record)) ;; Get buffer from recorded buffer name. <=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D (buf (get-buffer (bookmark-prop-get bmk-record 'buffer))) (forward-str (bookmark-get-front-context-string bmk-record)) (behind-str (bookmark-get-rear-context-string bmk-record)) (place (bookmark-get-position bmk-record))) (set-buffer (cond ((and file (file-readable-p file) (not (buffer-live-p buf))) (find-file-noselect file)) (buf) (t (signal 'bookmark-error-no-filename (list 'stringp file))))) (if place (goto-char place)) (when (and forward-str (search-forward forward-str (point-max) t)) (goto-char (match-beginning 0))) (when (and behind-str (search-backward behind-str (point-min) t)) (goto-char (match-end 0))) nil))