emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111966: * bookmark.el: Display the b


From: Karl Fogel
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111966: * bookmark.el: Display the bookmark list header similarly to the
Date: Thu, 07 Mar 2013 16:33:22 -0600
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111966
committer: Karl Fogel <address@hidden>
branch nick: trunk
timestamp: Thu 2013-03-07 16:33:22 -0600
message:
  * bookmark.el: 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
  <orontee {_AT_} gmail.com> with a few tweaks by me.
  
  (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.
  (bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames):
  Conditionalize the skipping of the inline header height.
modified:
  lisp/ChangeLog
  lisp/bookmark.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-03-07 16:08:33 +0000
+++ b/lisp/ChangeLog    2013-03-07 22:33:22 +0000
@@ -1,3 +1,22 @@
+2013-03-07  Karl Fogel  <address@hidden>
+
+       * bookmark.el: 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
+       <orontee {_AT_} gmail.com> with a few tweaks by me.
+
+       (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.
+       (bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames):
+       Conditionalize the skipping of the inline header height.
+
 2013-03-07  Dmitry Gutov  <address@hidden>
 
        * progmodes/js.el (js--multi-line-declaration-indentation): Merge

=== modified file 'lisp/bookmark.el'
--- a/lisp/bookmark.el  2013-01-02 16:13:04 +0000
+++ b/lisp/bookmark.el  2013-03-07 22:33:22 +0000
@@ -129,9 +129,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,
@@ -1552,7 +1558,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))
@@ -1577,8 +1584,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))))
 
@@ -1587,7 +1596,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.
@@ -1640,7 +1667,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)
@@ -1653,7 +1682,8 @@
      (save-excursion
        (save-window-excursion
          (goto-char (point-min))
-         (forward-line 2)
+        (if (not bookmark-bmenu-use-header-line)
+            (forward-line bookmark-bmenu-inline-header-height))
          (setq bookmark-bmenu-hidden-bookmarks ())
          (let ((inhibit-read-only t))
            (while (< (point) (point-max))
@@ -1681,7 +1711,8 @@
     (with-buffer-modified-unmodified
      (save-excursion
        (goto-char (point-min))
-       (forward-line 2)
+       (if (not bookmark-bmenu-use-header-line)
+          (forward-line bookmark-bmenu-inline-header-height))
        (setq bookmark-bmenu-hidden-bookmarks
              (nreverse bookmark-bmenu-hidden-bookmarks))
        (let ((inhibit-read-only t))
@@ -1705,9 +1736,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))))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]