From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: Patch to bookmark.el Date: Sun, 18 Dec 2011 00:30:49 -0500 Message-ID: <87pqfmcupi.fsf@floss.red-bean.com> References: <87zkeqhod2.fsf@floss.red-bean.com> Reply-To: Karl Fogel NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1324186266 17002 80.91.229.12 (18 Dec 2011 05:31:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 18 Dec 2011 05:31:06 +0000 (UTC) Cc: Matthias Meulien , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 18 06:31:02 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rc9Ks-0006iE-HZ for ged-emacs-devel@m.gmane.org; Sun, 18 Dec 2011 06:30:58 +0100 Original-Received: from localhost ([::1]:39655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rc9Kr-0007VK-Os for ged-emacs-devel@m.gmane.org; Sun, 18 Dec 2011 00:30:57 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:56092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rc9Kp-0007VF-9A for emacs-devel@gnu.org; Sun, 18 Dec 2011 00:30:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rc9Kn-000509-Uy for emacs-devel@gnu.org; Sun, 18 Dec 2011 00:30:55 -0500 Original-Received: from mail-qy0-f169.google.com ([209.85.216.169]:44212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rc9Kn-000505-PC for emacs-devel@gnu.org; Sun, 18 Dec 2011 00:30:53 -0500 Original-Received: by qcsd17 with SMTP id d17so2895192qcs.0 for ; Sat, 17 Dec 2011 21:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:references:reply-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=FxquYmLfGGjQLs0uvA2wLX2pkEM1aG40R79Nin86mLA=; b=XufG9Wi6fYLgOt35vf+LJK2H7pI1bNMZsnFHNZH/iwrMJviIxtuhVBnY7A9rJ2MTXC KUt6Lj2OAVHf/PRcYepUJunEUfE2orfNnIhTWNJAj0qln27bL4MOMs6nMws9RfFKXucq OuafUC5lC577gn8bdMhDs6zYKnKByAeCcKTC8= Original-Received: by 10.229.77.9 with SMTP id e9mr3718597qck.36.1324186253350; Sat, 17 Dec 2011 21:30:53 -0800 (PST) Original-Received: from floss.red-bean.com (cpe-66-65-49-129.nyc.res.rr.com. [66.65.49.129]) by mx.google.com with ESMTPS id hv20sm30992741qab.22.2011.12.17.21.30.50 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 17 Dec 2011 21:30:52 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Sat, 17 Dec 2011 17:22:47 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146794 Archived-At: --=-=-= Content-Type: text/plain Reposting the revised patch with a log message this time, to make review easier: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=meulien-patch-kfogel-revisions.txt Content-Description: Matthias Meulien's patch to modernize bookmark menu header display, revised and with log message by Karl Fogel. [[[ Display the bookmark list header similarly to the buffer list header (see `list-buffers'), where the default is now an immovable/immutable header line. Patch by: Matthias Meulien Karl Fogel * lisp/bookmark.el (bookmark-bmenu-use-header-line): New variable. (bookmark-bmenu-inline-header-height): New name for `bookmark-bmenu-header-height', to avoid confusion with the code for the new immovable header. All references changed. (bookmark-bmenu-set-header): New function. (bookmark-bmenu-list, bookmark-bmenu-toggle-filenames): Conditionalize header construction accordingly. (bookmark-bmenu-ensure-position): Conditionalize the skipping of the inline header height. ]]] === modified file 'lisp/bookmark.el' --- lisp/bookmark.el 2011-11-27 04:43:11 +0000 +++ lisp/bookmark.el 2011-12-17 21:32:01 +0000 @@ -127,9 +127,15 @@ :type 'boolean :group 'bookmark) +(defcustom bookmark-bmenu-use-header-line t + "Non-nil means to use an immovable header line, as opposed to inline +text at the top of the buffer." + :type 'boolean + :group 'bookmark) -(defconst bookmark-bmenu-header-height 2 - "Number of lines used for the *Bookmark List* header.") +(defconst bookmark-bmenu-inline-header-height 2 + "Number of lines used for the *Bookmark List* header +\(only significant when `bookmark-bmenu-use-header-line' is nil\).") (defconst bookmark-bmenu-marks-width 2 "Number of columns (chars) used for the *Bookmark List* marks column, @@ -1543,7 +1549,8 @@ (set-buffer buf))) (let ((inhibit-read-only t)) (erase-buffer) - (insert "% Bookmark\n- --------\n") + (if (not bookmark-bmenu-use-header-line) + (insert "% Bookmark\n- --------\n")) (add-text-properties (point-min) (point) '(font-lock-face bookmark-menu-heading)) (dolist (full-record (bookmark-maybe-sort-alist)) @@ -1568,8 +1575,10 @@ (insert "\n"))) (set-buffer-modified-p (not (= bookmark-alist-modification-count 0))) (goto-char (point-min)) - (forward-line 2) (bookmark-bmenu-mode) + (if bookmark-bmenu-use-header-line + (bookmark-bmenu-set-header) + (forward-line bookmark-bmenu-inline-header-height)) (if bookmark-bmenu-toggle-filenames (bookmark-bmenu-toggle-filenames t)))) @@ -1578,7 +1587,25 @@ ;;;###autoload (defalias 'edit-bookmarks 'bookmark-bmenu-list) - +(defun bookmark-bmenu-set-header () + "Sets the immutable header line." + (let ((header (concat "%% " "Bookmark"))) + (when bookmark-bmenu-toggle-filenames + (setq header (concat header + (make-string (- bookmark-bmenu-file-column + (- (length header) 3)) ?\s) + "File"))) + (let ((pos 0)) + (while (string-match "[ \t\n]+" header pos) + (setq pos (match-end 0)) + (put-text-property (match-beginning 0) pos 'display + (list 'space :align-to (- pos 1)) + header))) + (put-text-property 0 2 'face 'fixed-pitch header) + (setq header (concat (propertize " " 'display '(space :align-to 0)) + header)) + ;; Code derived from `buff-menu.el'. + (setq header-line-format header))) (define-derived-mode bookmark-bmenu-mode special-mode "Bookmark Menu" "Major mode for editing a list of bookmarks. @@ -1631,7 +1658,9 @@ (setq bookmark-bmenu-toggle-filenames nil)) (t (bookmark-bmenu-show-filenames) - (setq bookmark-bmenu-toggle-filenames t)))) + (setq bookmark-bmenu-toggle-filenames t))) + (when bookmark-bmenu-use-header-line + (bookmark-bmenu-set-header))) (defun bookmark-bmenu-show-filenames (&optional force) @@ -1696,9 +1725,11 @@ "If point is not on a bookmark line, move it to one. If before the first bookmark line, move to the first; if after the last full line, move to the last full line. The return value is undefined." - (cond ((< (count-lines (point-min) (point)) bookmark-bmenu-header-height) + (cond ((and (not bookmark-bmenu-use-header-line) + (< (count-lines (point-min) (point)) + bookmark-bmenu-inline-header-height)) (goto-char (point-min)) - (forward-line bookmark-bmenu-header-height)) + (forward-line bookmark-bmenu-inline-header-height)) ((and (bolp) (eobp)) (beginning-of-line 0)))) --=-=-=--