From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#4804: 23.1; bookmark-bmenu-bookmark performances Date: Sun, 25 Oct 2009 09:36:46 +0100 Organization: ThierryVolpiatto Message-ID: <87my3fzx7l.fsf@tux.homenetwork> Reply-To: Thierry Volpiatto , 4804@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1256461663 15269 80.91.229.12 (25 Oct 2009 09:07:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Oct 2009 09:07:43 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 25 10:07:36 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N1z4Z-0002xn-1m for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Oct 2009 10:07:35 +0100 Original-Received: from localhost ([127.0.0.1]:32863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1z4Y-0005XN-8H for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Oct 2009 05:07:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1z4S-0005X4-OE for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 05:07:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1z4N-0005Vj-96 for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 05:07:27 -0400 Original-Received: from [199.232.76.173] (port=59288 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1z4N-0005VX-3K for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 05:07:23 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:56046) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N1z4M-0000g6-BB for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 05:07:22 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9P97Dbb022763; Sun, 25 Oct 2009 02:07:13 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n9P8o5Km019388; Sun, 25 Oct 2009 01:50:05 -0700 Resent-Date: Sun, 25 Oct 2009 01:50:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Thierry Volpiatto Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sun, 25 Oct 2009 08:50:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4804 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125646017418376 (code B ref -1); Sun, 25 Oct 2009 08:50:05 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 25 Oct 2009 08:42:54 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9P8gqbm018373 for ; Sun, 25 Oct 2009 01:42:53 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1yge-0002So-FI for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 04:42:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1ygZ-0002PJ-0m for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 04:42:52 -0400 Original-Received: from [199.232.76.173] (port=33036 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1ygY-0002Oz-PK for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 04:42:46 -0400 Original-Received: from mail-ew0-f228.google.com ([209.85.219.228]:57108) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N1ygY-0006Aq-3Q for bug-gnu-emacs@gnu.org; Sun, 25 Oct 2009 04:42:46 -0400 Original-Received: by ewy28 with SMTP id 28so4224135ewy.42 for ; Sun, 25 Oct 2009 01:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:organization :date:message-id:user-agent:mime-version:content-type; bh=3Q9AgXvrYju9hSkq8d6NL+sHAk1HXzQuwR7Yo75Nnxw=; b=jGw42q/wxxUNAIl0I8hO5u50Z1jPKFtiIa6ttZajcf9fBLfuTAMtGrYyQPaVGCPc/r 4gMJ0B4FH928PKjIV0H7Luqx2oG6s39rOW+TrjEpXvGBUsIyuRUfy3T3uPPqoCZIydWB FVHuJyeFzrg2hXkx4UTbA9te/ci46ohhuSkRo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:organization:date:message-id:user-agent :mime-version:content-type; b=ToGG2yiyUZW91NWXwKLm1iI76wrG8TzZtzRHlFu0qbU3i9NEUNy8HWnb3ZvHWNWBaX BHqqus7GjY/9q4DTIqvUusUDPj7PmYUbE4Ggu8FbTTMa6ELeXQELC4ASOXQnhl/K5Nbe SVCIBKeb0hWO/0I2uAu4b423ULE/DXwrfDACk= Original-Received: by 10.211.126.15 with SMTP id d15mr2888693ebn.19.1256460164562; Sun, 25 Oct 2009 01:42:44 -0700 (PDT) Original-Received: from tux.homenetwork ([93.4.141.19]) by mx.google.com with ESMTPS id 7sm9986598eyb.40.2009.10.25.01.42.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 25 Oct 2009 01:42:44 -0700 (PDT) User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sun, 25 Oct 2009 05:07:27 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32230 Archived-At: --=-=-= Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. Please describe exactly what actions triggered the bug and the precise symptoms of the bug: Hi, About bookmark-bmenu-bookmark: This function work as expected but it is not convenient for the developper that work on bookmark.el, thus it is inefficient. bookmark-bmenu-bookmark parse all the menu list with search-* to get the bookmark name, but to do that, it have to toggle the filenames visibility if these are toggle on. That's the problem: 1) run a loop on all menu list to toggle filenames visibility. 2) come back to the original place and get bookmark name with buffer-substring 3) run again a loop to toggle filenames visibility back. That's very costly. If you want one bookmark name, ok but if you run another loop to get many bookmark names, that will be very long. The solution: (It's what i wrote for bookmark+.el.) 1) Create a defvar like `bookmark-latest-sorted-alist'. ,---- | (defvar bookmark-latest-sorted-alist nil) `---- 2) Set this variable to the copy of bookmark-alist obtained in bookmark-maybe-sort-alist: ,---- | (defun bookmark-maybe-sort-alist () | "Return a sorted copy of `bookmark-alist'. | If `bookmark-sort-flag' is nil return `bookmark-alist'. | The sorted copy of `bookmark-alist' is set to `sbookmark-latest-sorted-alist'." | (let ((bmk-alist (copy-alist bookmark-alist))) | (if bookmark-sort-flag | (setq bookmark-latest-sorted-alist | (sort bmk-alist #'(lambda (x y) (string-lessp (car x) (car y))))) | (setq bookmark-latest-sorted-alist bookmark-alist)))) `---- 3) Get the bookmark name from this list with the position in menu list: ,---- | (defun bookmark-bmenu-bookmark () | "Return a string which is bookmark of this line." | (let ((pos (- (line-number-at-pos) 3))) | (car (nth pos bookmark-latest-sorted-alist)))) `---- That simple and work fine here. You can now work on menu list of bookmarks without thinking at toggling filename visibility.(and it's much faster). That's make easier working in bookmark.el for further modification. You will find a patch attached. If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. If you would like to further debug the crash, please read the file /usr/share/emacs/23.1/etc/DEBUG for instructions. In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.16.5) of 2009-07-31 on tux Windowing system distributor `The X.Org Foundation', version 11.0.10603901 configured using `configure '--prefix=/usr' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--program-suffix=-emacs-23' '--infodir=/usr/share/info/emacs-23' '--with-sound' '--with-x' '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm' '--with-xft' '--without-libotf' '--without-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CFLAGS=-march=i686 -pipe -O2' 'LDFLAGS=-Wl,-O1'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: C value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: fr_FR.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default-enable-multibyte-characters: t Major mode: Lisp Minor modes in effect: eldoc-mode: t icomplete-mode: t icicle-mode: t delete-selection-mode: t minibuffer-depth-indicate-mode: t stumpwm-mode: t slime-mode: t auto-image-file-mode: t partial-completion-mode: t show-paren-mode: t display-battery-mode: t display-time-mode: t diff-auto-refine-mode: t shell-dirtrack-mode: t recentf-mode: t savehist-mode: t desktop-save-mode: t tooltip-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-x r l M-g e m a c s q p q M-x r e p o r t Recent messages: bunzip2ing elisp-9.info.bz2...done bunzip2ing elisp-10.info.bz2...done bunzip2ing elisp-11.info.bz2...done Turning ON Icicle mode...done Desktop lazily opening *info* (1 remaining)...done Lazy desktop load complete Collecting symbols...done Auto-saving...done Collecting symbols...done Computing completion candidates... -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=SingleInitial-patchToTip.patch ##Merge of all patches applied from revision 0 ## Initial-patch: New definition of bookmark-bmenu-bookmark by string comparison.(no need to toggle filenames every time). ## patch-r2: Set bookmarkp-latest-sorted-alist to bookmark-alist value when not sorting. ## diff --git a/bookmark.el b/bookmark.el --- a/bookmark.el +++ b/bookmark.el @@ -922,14 +922,15 @@ (setq bookmarks-already-loaded t))) +(defvar bookmarkp-latest-sorted-alist nil) (defun bookmark-maybe-sort-alist () ;;Return the bookmark-alist for display. If the bookmark-sort-flag ;;is non-nil, then return a sorted copy of the alist. - (if bookmark-sort-flag - (sort (copy-alist bookmark-alist) - (function - (lambda (x y) (string-lessp (car x) (car y))))) - bookmark-alist)) + (let ((bmk-alist (copy-alist bookmark-alist))) + (if bookmark-sort-flag + (setq bookmarkp-latest-sorted-alist + (sort bmk-alist #'(lambda (x y) (string-lessp (car x) (car y))))) + (setq bookmarkp-latest-sorted-alist bookmark-alist)))) (defvar bookmark-after-jump-hook nil @@ -1670,28 +1671,9 @@ (defun bookmark-bmenu-bookmark () - ;; return a string which is bookmark of this line. - (if (bookmark-bmenu-check-position) - (save-excursion - (save-window-excursion - (goto-char (point-min)) - (search-forward "Bookmark") - (backward-word 1) - (setq bookmark-bmenu-bookmark-column (current-column))))) - (if bookmark-bmenu-toggle-filenames - (bookmark-bmenu-hide-filenames)) - (save-excursion - (save-window-excursion - (beginning-of-line) - (forward-char bookmark-bmenu-bookmark-column) - (prog1 - (buffer-substring-no-properties (point) - (progn - (end-of-line) - (point))) - ;; well, this is certainly crystal-clear: - (if bookmark-bmenu-toggle-filenames - (bookmark-bmenu-toggle-filenames t)))))) + "Return a string which is bookmark of this line." + (let ((pos (- (line-number-at-pos) 3))) + (car (nth pos bookmarkp-latest-sorted-alist)))) (defun bookmark-show-annotation (bookmark) @@ -1936,8 +1918,7 @@ "Delete bookmarks marked with \\\\[Buffer-menu-delete] commands." (interactive) (message "Deleting bookmarks...") - (let ((hide-em bookmark-bmenu-toggle-filenames) - (o-point (point)) + (let ((o-point (point)) (o-str (save-excursion (beginning-of-line) (if (looking-at "^D") @@ -1946,16 +1927,11 @@ (point) (progn (end-of-line) (point)))))) (o-col (current-column))) - (if hide-em (bookmark-bmenu-hide-filenames)) - (setq bookmark-bmenu-toggle-filenames nil) (goto-char (point-min)) (forward-line 1) (while (re-search-forward "^D" (point-max) t) (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg (bookmark-bmenu-list) - (setq bookmark-bmenu-toggle-filenames hide-em) - (if bookmark-bmenu-toggle-filenames - (bookmark-bmenu-toggle-filenames t)) (if o-str (progn (goto-char (point-min)) --=-=-=--