From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] When deleting in bookmark menu, prompt for confirmation. Date: Wed, 05 May 2021 00:24:07 -0500 Message-ID: <87mtt9sqh4.fsf@red-bean.com> References: <87a6pcqy7s.fsf@red-bean.com> <83czu86o46.fsf@gnu.org> <835z006jpl.fsf@gnu.org> <87im3z3f8f.fsf@red-bean.com> <83zgxb67g2.fsf@gnu.org> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8029"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 05 07:24:50 2021 Return-path: Envelope-to: ged-emacs-devel@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 1leA1h-0001za-Dz for ged-emacs-devel@m.gmane-mx.org; Wed, 05 May 2021 07:24:49 +0200 Original-Received: from localhost ([::1]:54512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leA1g-0007LQ-Gr for ged-emacs-devel@m.gmane-mx.org; Wed, 05 May 2021 01:24:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leA17-0006vb-FA for emacs-devel@gnu.org; Wed, 05 May 2021 01:24:13 -0400 Original-Received: from sanpietro.red-bean.com ([45.79.25.59]:54554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leA15-00087I-12 for emacs-devel@gnu.org; Wed, 05 May 2021 01:24:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=red-bean.com; s=202005newsp; h=Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:Reply-To:References:Subject:To:From:Sender:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1/PTNmYU+Amw9b0KZztzdOk7HXlSEOe3KxNyzrhcwaA=; t=1620192249; x=1621401849; b=K9p/PLQKir5Txacl7LkJUlFP9a6xTLvS1EcZGtgrotgGV0yNNIsjRhGi3Jv37x/XpCVb033tBI z19yKQr3Cp32GZwNjxi5DLIJQH1tG2v5y1KbsLlMufh9lH5zh9bddbw0x3dljS3TsU1l2qf5zgwjt 1w+7OX4Nj1H+3jNl3EFPc/sUqFYRL09tUO2uzFLRF6tALaITij1/NUTOWMpvFh4bvun/P2SexusDZ h5aSJIHVMcE5Ew7tBGkl2v7vpFrguOC5NAlRpEhGDLd2ZIHy68fLLrflH0oz9OgI2QOnGiN7UcJpQ zCxQ1SCtjTpENUT0Aa7kl2oAi1p8lZm0nUaCw==; Original-Received: from 99-112-125-163.lightspeed.cicril.sbcglobal.net ([99.112.125.163]:48262 helo=floss) by sanpietro.red-bean.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1leA12-0005lI-8s for emacs-devel@gnu.org; Wed, 05 May 2021 05:24:08 +0000 In-Reply-To: <83zgxb67g2.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 03 May 2021 20:41:33 +0300") Received-SPF: pass client-ip=45.79.25.59; envelope-from=kfogel@red-bean.com; helo=sanpietro.red-bean.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:268896 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Revised patch attached, with the option now defaulting to nil (i.e., to the old behavior) as per discussion. Review/comments welcome. Lars, you wrote this regarding v1 of this patch: >...the first line [of the doc string] should be a complete >sentence. It actually was a complete sentence even in v1, but I think I know what you meant. However, the "Non-nil means..." phrasing is found throughout Emacs -- I counted over 1000 places with this quick check: $ find lisp -name "*.el" | xargs grep '"Non-nil means' (One can add '-C3' to grep to see that they are indeed `defcustom's and `defvar's.) I guess that people are used to it, so I left that phrasing as-is. Best regards, -Karl --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=bookmark-menu-deletion-confirmation-patch-v2.txt [[[ New option to confirm deletion in bookmark menu * lisp/bookmark.el (bookmark-menu-confirm-deletion): New defcustom. (bookmark-delete-all): Add comment explaining why we don't use the new confirmation formula here. (bookmark-bmenu-execute-deletions): Conditionally confirm deletion. Note that the bulk of the code diff here is just reindentation of an otherwise unchanged `let' expression. * etc/NEWS: Announce the new option. Thanks to Lars Ingebrigtsen and Eli Zaretskii for review, and thanks to Oliver Taylor for suggesting the option in the first place: https://lists.gnu.org/archive/html/emacs-humanities/2021-02/msg00022.html From: Oliver Taylor Subject: Re: [emacs-humanities] Extending Emacs Bookmarks to Work with EWW To: Karl Fogel Cc: Stefan Kangas, Emacs-humanities mailing list Date: Wed, 3 Feb 2021 20:21:59 -0800 Message-Id: <936D47EA-4D11-452B-8303-971B6386877B@me.com> ]]] --- etc/NEWS +++ etc/NEWS @@ -276,6 +276,14 @@ commands. The new keystrokes are 'C-x x g' ('revert-buffer'), ** Commands 'set-frame-width' and 'set-frame-height' can now get their input using the minibuffer. +--- +** New user option 'bookmark-menu-confirm-deletion' +In Bookmark Menu mode, Emacs by default does not prompt for +confirmation when you type 'x' to execute the deletion of bookmarks +that have been marked for deletion. However, if this new option is +non-nil then Emacs will require confirmation with 'yes-or-no-p' before +deleting. + * Editing Changes in Emacs 28.1 --- lisp/bookmark.el +++ lisp/bookmark.el @@ -121,6 +121,13 @@ bookmark-sort-flag :type 'boolean) +(defcustom bookmark-menu-confirm-deletion nil + "Non-nil means prompt for confirmation when executing the deletion +of bookmarks marked for deletion in a bookmark menu buffer; nil +means don't prompt for confirmation." + :version "28.1" + :type 'boolean) + (defcustom bookmark-automatically-show-annotations t "Non-nil means show annotations when jumping to a bookmark." :type 'boolean) @@ -1376,6 +1383,13 @@ bookmark-delete-all If optional argument NO-CONFIRM is non-nil, don't ask for confirmation." (interactive "P") + ;; We don't use `bookmark-menu-confirm-deletion' here because that + ;; variable is specifically to control confirmation prompting in a + ;; bookmark menu buffer, where the user has the marked-for-deletion + ;; bookmarks arrayed in front of them and might have accidentally + ;; hit the key that executes the deletions. The UI situation here + ;; is quite different, by contrast: the user got to this point by a + ;; sequence of keystrokes unlikely to be typed by chance. (when (or no-confirm (yes-or-no-p "Permanently delete all bookmarks? ")) (bookmark-maybe-load-default-file) @@ -2142,30 +2156,35 @@ bookmark-bmenu-delete-all (defun bookmark-bmenu-execute-deletions () - "Delete bookmarks flagged `D'." + "Delete bookmarks flagged `D'. +If `bookmark-menu-confirm-deletion' is non-nil, prompt for +confirmation first." (interactive nil bookmark-bmenu-mode) - (let ((reporter (make-progress-reporter "Deleting bookmarks...")) - (o-point (point)) - (o-str (save-excursion - (beginning-of-line) - (unless (= (following-char) ?D) - (buffer-substring - (point) - (progn (end-of-line) (point)))))) - (o-col (current-column))) - (goto-char (point-min)) - (while (re-search-forward "^D" (point-max) t) - (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg - (bookmark-bmenu-list) - (if o-str - (progn - (goto-char (point-min)) - (search-forward o-str) - (beginning-of-line) - (forward-char o-col)) - (goto-char o-point)) - (beginning-of-line) - (progress-reporter-done reporter))) + (if (and bookmark-menu-confirm-deletion + (not (yes-or-no-p "Delete selected bookmarks? "))) + (message "Bookmarks not deleted.") + (let ((reporter (make-progress-reporter "Deleting bookmarks...")) + (o-point (point)) + (o-str (save-excursion + (beginning-of-line) + (unless (= (following-char) ?D) + (buffer-substring + (point) + (progn (end-of-line) (point)))))) + (o-col (current-column))) + (goto-char (point-min)) + (while (re-search-forward "^D" (point-max) t) + (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg + (bookmark-bmenu-list) + (if o-str + (progn + (goto-char (point-min)) + (search-forward o-str) + (beginning-of-line) + (forward-char o-col)) + (goto-char o-point)) + (beginning-of-line) + (progress-reporter-done reporter)))) (defun bookmark-bmenu-rename () --=-=-=--