From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gabriel Newsgroups: gmane.emacs.bugs Subject: bug#59580: 29.0.50; [PATCH] Add new choices to bookmark-sort-flag Date: Fri, 25 Nov 2022 15:26:49 -0300 Message-ID: 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="17844"; mail-complaints-to="usenet@ciao.gmane.io" To: 59580@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 25 19:28:19 2022 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 1oydQx-0004Q5-Am for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Nov 2022 19:28:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oydQk-0008LB-MX; Fri, 25 Nov 2022 13:28:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oydQi-0008Kk-AV for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 13:28:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oydQg-0005Bq-4T for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 13:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oydQf-0003SC-Vj for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 13:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gabriel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Nov 2022 18:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59580 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166940082613211 (code B ref -1); Fri, 25 Nov 2022 18:28:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Nov 2022 18:27:06 +0000 Original-Received: from localhost ([127.0.0.1]:37139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oydPl-0003R0-UX for submit@debbugs.gnu.org; Fri, 25 Nov 2022 13:27:06 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oydPh-0003Qd-K0 for submit@debbugs.gnu.org; Fri, 25 Nov 2022 13:27:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oydPg-0008F8-IT for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 13:27:00 -0500 Original-Received: from mail-bn8nam11olkn2010.outbound.protection.outlook.com ([40.92.20.10] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oydPe-0003du-6B for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 13:27:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YT2HadG+fwynudeZuATcRp6e03IaLYIZFxyr4ekaRwgvXuXKXuzXxsyKJlwL3LrchWU8phX1KIoa2m/CFb7ye2OyvWaOk2Fe14gItwIvMCnEwvYSwhND5cRBmyBMEcWbbEf2XTvDSnBN2edf4qKcwf7dAnokMaevEuuKpUi1iGu+z3QVk6IAPRCsCV8wTky4cIzUB4SY3wLyDGbkYWJHs1a7fsZyBSgMOh4y1Cn8Xool1ghU8eYIpYSNNrpEDLSRXJKIjT7kU3u9d7mLI272f+tTtPuq2XLcQNcVp+29u66KWsjgwD4/TnJjdRVg/bL3eAksjvqO5kC5HAefV1d4aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FXwsf5cAXiCL0VkhjUQMZCAGvbX72Ohu7IcC6TJhFYk=; b=i425YuahzDGrAO4zNCmvomJ5cDan83ZyCmKxC2FZ8Hux0vr0v/Rj2vvNFpqYKADErnr5vCVP5SuL/6RvH7QPtlgBS3BYj0a2MIXQYi7UzaWZl9T8vBztgKxrewf4KBAHZcDNvQ0teGDmr8JP6/ZmtOt8EwRTQY5GxnrUHCj9C3HbbrCBgSPiOeaUacypu7/TEszU1umbXC84OK/SwE5QRKKz8ej5dC4blQt2y2bA8vCcn3WhmpZTWzyP/g32QVTsoj85yw6mgFsF0fQVzJQy20VQw1gHQWo4qVQ4vg9Yy2FxablzTI1qQMLvsHybJMKRaldUobNG3tGRx5TCLd7Rog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FXwsf5cAXiCL0VkhjUQMZCAGvbX72Ohu7IcC6TJhFYk=; b=kLPXLXb9jOOWGMEk6hDhF49A7xv5mjETYQtfT4mn1d8T3VYTHuAvH6oaxpO4haEmmREv+GRbsovvpx5ZBRYwAJ8UJxCHhB22YIamtIOIarCcI6n74x9RsAihIp0cpFwMm7DiDA/3xgwls91qzT/Nb8WZaeuAV1BUHWcOhfjjEtZNoSKH+hZ5yU8wobCM5zQ6gvh8LHlX2UUeHzXPrKHybDy0YpKvPlFueUXpPDiAG4GV2IeckzYzJLYMh2koIqL6DC4DIxFidtwf7oPjeVNweBlguzAHLcmkQ3s1GjExNlALivTmwKEVIo1+LxI5zFPv/NvSxu9iCrfGbz9GjPOocg== Original-Received: from SJ0PR06MB8609.namprd06.prod.outlook.com (2603:10b6:a03:40c::11) by BYAPR06MB4646.namprd06.prod.outlook.com (2603:10b6:a03:41::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Fri, 25 Nov 2022 18:26:55 +0000 Original-Received: from SJ0PR06MB8609.namprd06.prod.outlook.com ([fe80::33ae:d3a7:24ae:5c6f]) by SJ0PR06MB8609.namprd06.prod.outlook.com ([fe80::33ae:d3a7:24ae:5c6f%5]) with mapi id 15.20.5880.005; Fri, 25 Nov 2022 18:26:55 +0000 X-TMN: [vvrsjYpo1S4CK0iOdepVYazHtJUI4rSuvX1srY8xxJfOQ4/VMIPLpf2PxYnpJjRt] X-ClientProxiedBy: CP3P284CA0124.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:6a::9) To SJ0PR06MB8609.namprd06.prod.outlook.com (2603:10b6:a03:40c::11) X-Microsoft-Original-Message-ID: <87wn7ic2l2.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR06MB8609:EE_|BYAPR06MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: b9231a89-b3fe-45ee-fe70-08dacf12a125 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mgFOYMDi7rdpH4KogVF2ZGyxLDZGqtVMY1pHEWVfLQff6MYNJ6l0DWi6IC5F28MGrstZED36xlUEivEsreDZeGF5xUQ3fyYRxC8H4a55BsnjvO9RegjwkLzXW2dgxFz+C2+tWt2rUzOWSbByShLUZZ2J5HfIRJnz5e0H2oXu9fHu++J7gcNNeBNQBL7FIvpWXCcyzKSbYnP8gHgmEyE56xLKc37mlFtgprB5ke+GE+i7y2TNfhthE80h0a0fmuL2etzcWNkQ/aQfKTJ9sy4mBYx+CQ4+D3VTxsupvFBoxFCgaTt9IGxb/+1wnljgJ6atleHwa47FBfOQmVwpzKuLROirU1ZRxeTPWuWlbRA6Ml2uJMoicz5WeG35hm0VYnepkIyzedOnCWNPOBZMeG4Ggs5I5agNKXQ6WNogG8VcZikwU9ZaBkEHFR/dfO4sslMMi9BhKKT8pbLf0y/mQy2Tc/lWqCr0yPSKF37FGgKCWOZ+VN4BnzmjB/Hxjd0gu9y41mfHYMedY5wNXARCESeyP0G0uui4hTHfstsMCpStmQovUVaqBXKDW0OwYpGyMFlPJT46JlGJJ8g5tzQiulKRMHox0ril1nl6eHHejvoBUag= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TQv8XoPj0B7HLS3rmOCD+32t/zCY52NQPuXOLKiI5rybP525dqKT9ZypNObNa5BqV0g5RpHDuGKvuRAINGOy8kC97r8xOMCQPPveei8VIblVDUecz9t1fIc4UPG71Qw8r8ti2ib4+bBGWW6Srwdz4pIj2DVLQCrASshLyxOMET24FU4oNY2hdcWM0ce4oC2CsPxTPpNmvrNcyYr17EnFGj3/EiC0tka7rL8+RUTjY6pro5IOEMYame7n3BHgasegHjz+qK+2GlRQeUf3O9g7qed70gE7kVwxOfp2IXOiJZRWGWx7mRBsQQ/RjPvGENDa/jbxtHx2NjPQl63ocdYOsP8031+zy4zL4DIEF29XI7gCKnKHvxQy1dNneCmyEm+DVomp9rowO8bUU3C9KpiDJjWV04swUZcjwVMTQr0erhlZS0N6B+5ZSA63+YHCy2s/DddnHVh51/+wCd4UouqLzoNBfLEP9z5WpAaybFe28GC6wuoJNdZKLcPd08wGaIy3V8O90vPS48Eldvo2jD5NeRkkBgg1emxeLuO2DnIKvPeCL0o4o2XdYYDfN+z6Nohy1dJUSnI+2A95j7xPtLLyR01RS4lW3Gi0nENyqFSvUGnDiQl2ZwQpQKOIuub25uaLiSG+7DAW+mbVrriv16+YxjER50XniIp1EWMHX+SYDgWtEN4lF44PMPV66Kp0V030M+mnooC9IOB/JqcsMM+WluDjHjWb1+IIcWwNmDrrusu5rrNaS9zR/EA527 Dvt4GokCGIP7cEYSGnDSuE/h22tXAsymBF/1j4u1FB2C6KBcBQV2bE1Sm23b3Gby9dQu8K4eCVHyzWR/w/FNX+mp2EK2vKVuOD X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-89723.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: b9231a89-b3fe-45ee-fe70-08dacf12a125 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR06MB8609.namprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2022 18:26:55.2295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB4646 Received-SPF: pass client-ip=40.92.20.10; envelope-from=gabriel376@hotmail.com; helo=NAM11-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249022 Archived-At: --=-=-= Content-Type: text/plain Severity: wishlist Description: Add new choices 'type and 'file to `bookmark-sort-flag'. See [1]. Notes: 1) It feels strange to have value t meaning 'name and value nil meaning 'creation-time, but it's better to not change how things have been working for many years. A more flexible approach could offer a custom function as a choice of `bookmark-sort-flag'. 2) I took the liberty to update some comments and docstrings, please review. 3) I took the liberty to remove some code in `bookmark-bmenu-mode' that seems to be unnecessary, please review. Everything seems to be working as expected according to my tests. I can also write some tests. 4) Used `string-collate-lessp' in `bookmark-maybe-sort-alist' to match `bookmark-bmenu--*-predicate' functions. [1] https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00995.html --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-more-choices-to-bookmark-sort-flag.patch >From c41d0990774a39a942e645aeaaec1126de419db1 Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Fri, 25 Nov 2022 15:06:58 -0300 Subject: [PATCH 1/1] Add more choices to bookmark-sort-flag * lisp/bookmark.el (bookmark-sort-flag): Add new choices 'type and 'file. (bookmark-maybe-sort-alist, bookmark-bmenu-mode): Handle new choices of `bookmark-sort-flag'. (bookmark-bmenu-mode): Update docstring and remove unnecessary code. * etc/NEWS: Announce the changes. --- etc/NEWS | 5 ++-- lisp/bookmark.el | 69 +++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 0ffc849fec..acd0ed1d6e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2554,9 +2554,8 @@ Types are registered via a 'bookmark-handler-type' symbol property on the jumping function. +++ -*** 'bookmark-sort-flag' can now be set to 'last-modified'. -This will display bookmark list from most recently set to least -recently set. +*** 'bookmark-sort-flag' now accepts more choices. +It now accepts the values 'type', 'file' and 'last-modified'. --- *** When editing a bookmark annotation, 'C-c C-k' will now cancel. diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 7f3a264f53..084f7450fe 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -38,13 +38,6 @@ (require 'fringe) ; for builds --without-x (eval-when-compile (require 'cl-lib)) -;;; Misc comments: -;; -;; The bookmark list is sorted lexically by default, but you can turn -;; this off by setting bookmark-sort-flag to nil. If it is nil, then -;; the list will be presented in the order it is recorded -;; (chronologically), which is actually fairly useful as well. - ;;; User Variables (defgroup bookmark nil @@ -116,16 +109,16 @@ bookmark-completion-ignore-case (defcustom bookmark-sort-flag t - "This controls the bookmark display sorting. -nil means they will be displayed in LIFO order (that is, most -recently created ones come first, oldest ones come last). - -`last-modified' means that bookmarks will be displayed sorted -from most recently modified to least recently modified. + "Controls the bookmark display sorting. -Other values means that bookmarks will be displayed sorted by -bookmark name." +A value of t means to display bookmarks sorted by name. A value +of `type' means to display bookmarks sorted by type. A value of +`file' means to display bookmarks sorted by file. A value of +`last-modified' means to display bookmarks by modification time. +A value of nil means to display bookmarks by creation time." :type '(choice (const :tag "By name" t) + (const :tag "By type" type) + (const :tag "By file" file) (const :tag "By modified time" last-modified) (const :tag "By creation time" nil))) @@ -524,14 +517,22 @@ bookmark--remove-fringe-mark (delete-overlay (setq found temp)))))))))) (defun bookmark-maybe-sort-alist () - "Return `bookmark-alist' for display. -If `bookmark-sort-flag' is T, then return a sorted by name copy of the alist. -If `bookmark-sort-flag' is LAST-MODIFIED, then return a sorted by last modified -copy of the alist. Otherwise, just return `bookmark-alist', which by default -is ordered from most recently created to least recently created bookmark." + "Return a copy of `bookmark-alist' for display. + +The sort order is controlled by `bookmark-sort-flag'." (let ((copy (copy-alist bookmark-alist))) (cond ((eq bookmark-sort-flag t) - (sort copy (lambda (x y) (string-lessp (car x) (car y))))) + (sort copy (lambda (x y) + (string-collate-lessp (bookmark-name-from-full-record x) + (bookmark-name-from-full-record y))))) + ((eq bookmark-sort-flag 'type) + (sort copy (lambda (x y) + (string-collate-lessp (bookmark-type-from-full-record x) + (bookmark-type-from-full-record y))))) + ((eq bookmark-sort-flag 'file) + (sort copy (lambda (x y) + (string-collate-lessp (bookmark-location x) + (bookmark-location y))))) ((eq bookmark-sort-flag 'last-modified) (sort copy (lambda (x y) (let ((tx (bookmark-get-last-modified x)) @@ -1903,6 +1904,12 @@ bookmark-bmenu--revert (cond ((eq bookmark-sort-flag t) (setq tabulated-list-sort-key '("Bookmark Name" . nil) tabulated-list-entries entries)) + ((eq bookmark-sort-flag 'type) + (setq tabulated-list-sort-key '("Type" . nil) + tabulated-list-entries entries)) + ((eq bookmark-sort-flag 'file) + (setq tabulated-list-sort-key '("File" . nil) + tabulated-list-entries entries)) ((or (null bookmark-sort-flag) (eq bookmark-sort-flag 'last-modified)) (setq tabulated-list-sort-key nil) @@ -1971,16 +1978,10 @@ bookmark-bmenu-mode Letters do not insert themselves; instead, they are commands. Bookmark names preceded by a \"*\" have annotations. -If `bookmark-sort-flag' is non-nil, then sort the list by -bookmark name (case-insensitively, in collation order); the -direction of that sort can be reversed by using the column sort -toggle for the bookmark name column. - -If `bookmark-sort-flag' is nil, then sort the list by bookmark -creation order, with most recently created bookmarks on top. -However, the column sort toggle will still activate (and -thereafter toggle the direction of) lexical sorting by bookmark name. -At any time you may use \\[revert-buffer] to go back to sorting by creation order. +The sort order can be controlled with `bookmark-sort-flag'. The +sort direction can be reversed by using the column sort toggle +for the bookmark name column. At any time you may use +\\[revert-buffer] to go back to the original sort order. \\ \\[bookmark-bmenu-mark] -- mark bookmark to be displayed. @@ -2015,8 +2016,7 @@ bookmark-bmenu-mode \\[bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer. \\[bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark. \\[bookmark-bmenu-search] -- incrementally search for bookmarks. -\\[revert-buffer] -- refresh the buffer, and thus refresh the sort order (useful - if `bookmark-sort-flag' is nil)." +\\[revert-buffer] -- refresh the buffer, and thus refresh the sort order." (setq truncate-lines t) (setq buffer-read-only t) ;; FIXME: The header could also display the current default bookmark file @@ -2029,9 +2029,6 @@ bookmark-bmenu-mode ,@(if bookmark-bmenu-toggle-filenames '(("File" 0 bookmark-bmenu--file-predicate)))]) (setq tabulated-list-padding bookmark-bmenu-marks-width) - (when (and bookmark-sort-flag - (not (eq bookmark-sort-flag 'last-modified))) - (setq tabulated-list-sort-key '("Bookmark Name" . nil))) (add-hook 'tabulated-list-revert-hook #'bookmark-bmenu--revert nil t)' (setq revert-buffer-function 'bookmark-bmenu--revert) (tabulated-list-init-header)) -- 2.34.1 --=-=-= Content-Type: text/plain --- Gabriel --=-=-=--