diff options
| author | Karl Fogel | 2013-03-07 16:33:22 -0600 |
|---|---|---|
| committer | Karl Fogel | 2013-03-07 16:33:22 -0600 |
| commit | 7a78e19f24ff07f5e57c63758ee4a98dd61453fb (patch) | |
| tree | 1aa4feb653ffc0334b78f4106b3650b4f1932774 | |
| parent | 94e48c7d758beb0845ba16fd8ff12de6999e5d55 (diff) | |
| download | emacs-7a78e19f24ff07f5e57c63758ee4a98dd61453fb.tar.gz emacs-7a78e19f24ff07f5e57c63758ee4a98dd61453fb.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/bookmark.el | 53 |
2 files changed, 62 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 709242e6006..f1ca958044b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2013-03-07 Karl Fogel <kfogel@red-bean.com> | ||
| 2 | |||
| 3 | * bookmark.el: Display the bookmark list header similarly to the | ||
| 4 | buffer list header (see `list-buffers'), where the default is now | ||
| 5 | an immovable/immutable header line. Patch by Matthias Meulien | ||
| 6 | <orontee {_AT_} gmail.com> with a few tweaks by me. | ||
| 7 | |||
| 8 | (bookmark-bmenu-use-header-line): New variable. | ||
| 9 | (bookmark-bmenu-inline-header-height): New name for | ||
| 10 | `bookmark-bmenu-header-height', to avoid confusion with the code | ||
| 11 | for the new immovable header. All references changed. | ||
| 12 | (bookmark-bmenu-set-header): New function. | ||
| 13 | (bookmark-bmenu-list, bookmark-bmenu-toggle-filenames): | ||
| 14 | Conditionalize header construction accordingly. | ||
| 15 | (bookmark-bmenu-ensure-position): Conditionalize the skipping of | ||
| 16 | the inline header height. | ||
| 17 | (bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames): | ||
| 18 | Conditionalize the skipping of the inline header height. | ||
| 19 | |||
| 1 | 2013-03-07 Dmitry Gutov <dgutov@yandex.ru> | 20 | 2013-03-07 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 21 | ||
| 3 | * progmodes/js.el (js--multi-line-declaration-indentation): Merge | 22 | * progmodes/js.el (js--multi-line-declaration-indentation): Merge |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index da6ffb38452..fd6ae217bf8 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -129,9 +129,15 @@ recently set ones come first, oldest ones come last)." | |||
| 129 | :type 'boolean | 129 | :type 'boolean |
| 130 | :group 'bookmark) | 130 | :group 'bookmark) |
| 131 | 131 | ||
| 132 | (defcustom bookmark-bmenu-use-header-line t | ||
| 133 | "Non-nil means to use an immovable header line, as opposed to inline | ||
| 134 | text at the top of the buffer." | ||
| 135 | :type 'boolean | ||
| 136 | :group 'bookmark) | ||
| 132 | 137 | ||
| 133 | (defconst bookmark-bmenu-header-height 2 | 138 | (defconst bookmark-bmenu-inline-header-height 2 |
| 134 | "Number of lines used for the *Bookmark List* header.") | 139 | "Number of lines used for the *Bookmark List* header |
| 140 | \(only significant when `bookmark-bmenu-use-header-line' is nil\).") | ||
| 135 | 141 | ||
| 136 | (defconst bookmark-bmenu-marks-width 2 | 142 | (defconst bookmark-bmenu-marks-width 2 |
| 137 | "Number of columns (chars) used for the *Bookmark List* marks column, | 143 | "Number of columns (chars) used for the *Bookmark List* marks column, |
| @@ -1552,7 +1558,8 @@ deletion, or > if it is flagged for displaying." | |||
| 1552 | (set-buffer buf))) | 1558 | (set-buffer buf))) |
| 1553 | (let ((inhibit-read-only t)) | 1559 | (let ((inhibit-read-only t)) |
| 1554 | (erase-buffer) | 1560 | (erase-buffer) |
| 1555 | (insert "% Bookmark\n- --------\n") | 1561 | (if (not bookmark-bmenu-use-header-line) |
| 1562 | (insert "% Bookmark\n- --------\n")) | ||
| 1556 | (add-text-properties (point-min) (point) | 1563 | (add-text-properties (point-min) (point) |
| 1557 | '(font-lock-face bookmark-menu-heading)) | 1564 | '(font-lock-face bookmark-menu-heading)) |
| 1558 | (dolist (full-record (bookmark-maybe-sort-alist)) | 1565 | (dolist (full-record (bookmark-maybe-sort-alist)) |
| @@ -1577,8 +1584,10 @@ deletion, or > if it is flagged for displaying." | |||
| 1577 | (insert "\n"))) | 1584 | (insert "\n"))) |
| 1578 | (set-buffer-modified-p (not (= bookmark-alist-modification-count 0))) | 1585 | (set-buffer-modified-p (not (= bookmark-alist-modification-count 0))) |
| 1579 | (goto-char (point-min)) | 1586 | (goto-char (point-min)) |
| 1580 | (forward-line 2) | ||
| 1581 | (bookmark-bmenu-mode) | 1587 | (bookmark-bmenu-mode) |
| 1588 | (if bookmark-bmenu-use-header-line | ||
| 1589 | (bookmark-bmenu-set-header) | ||
| 1590 | (forward-line bookmark-bmenu-inline-header-height)) | ||
| 1582 | (if bookmark-bmenu-toggle-filenames | 1591 | (if bookmark-bmenu-toggle-filenames |
| 1583 | (bookmark-bmenu-toggle-filenames t)))) | 1592 | (bookmark-bmenu-toggle-filenames t)))) |
| 1584 | 1593 | ||
| @@ -1587,7 +1596,25 @@ deletion, or > if it is flagged for displaying." | |||
| 1587 | ;;;###autoload | 1596 | ;;;###autoload |
| 1588 | (defalias 'edit-bookmarks 'bookmark-bmenu-list) | 1597 | (defalias 'edit-bookmarks 'bookmark-bmenu-list) |
| 1589 | 1598 | ||
| 1590 | 1599 | (defun bookmark-bmenu-set-header () | |
| 1600 | "Sets the immutable header line." | ||
| 1601 | (let ((header (concat "%% " "Bookmark"))) | ||
| 1602 | (when bookmark-bmenu-toggle-filenames | ||
| 1603 | (setq header (concat header | ||
| 1604 | (make-string (- bookmark-bmenu-file-column | ||
| 1605 | (- (length header) 3)) ?\s) | ||
| 1606 | "File"))) | ||
| 1607 | (let ((pos 0)) | ||
| 1608 | (while (string-match "[ \t\n]+" header pos) | ||
| 1609 | (setq pos (match-end 0)) | ||
| 1610 | (put-text-property (match-beginning 0) pos 'display | ||
| 1611 | (list 'space :align-to (- pos 1)) | ||
| 1612 | header))) | ||
| 1613 | (put-text-property 0 2 'face 'fixed-pitch header) | ||
| 1614 | (setq header (concat (propertize " " 'display '(space :align-to 0)) | ||
| 1615 | header)) | ||
| 1616 | ;; Code derived from `buff-menu.el'. | ||
| 1617 | (setq header-line-format header))) | ||
| 1591 | 1618 | ||
| 1592 | (define-derived-mode bookmark-bmenu-mode special-mode "Bookmark Menu" | 1619 | (define-derived-mode bookmark-bmenu-mode special-mode "Bookmark Menu" |
| 1593 | "Major mode for editing a list of bookmarks. | 1620 | "Major mode for editing a list of bookmarks. |
| @@ -1640,7 +1667,9 @@ Optional argument SHOW means show them unconditionally." | |||
| 1640 | (setq bookmark-bmenu-toggle-filenames nil)) | 1667 | (setq bookmark-bmenu-toggle-filenames nil)) |
| 1641 | (t | 1668 | (t |
| 1642 | (bookmark-bmenu-show-filenames) | 1669 | (bookmark-bmenu-show-filenames) |
| 1643 | (setq bookmark-bmenu-toggle-filenames t)))) | 1670 | (setq bookmark-bmenu-toggle-filenames t))) |
| 1671 | (when bookmark-bmenu-use-header-line | ||
| 1672 | (bookmark-bmenu-set-header))) | ||
| 1644 | 1673 | ||
| 1645 | 1674 | ||
| 1646 | (defun bookmark-bmenu-show-filenames (&optional force) | 1675 | (defun bookmark-bmenu-show-filenames (&optional force) |
| @@ -1653,7 +1682,8 @@ mainly for debugging, and should not be necessary in normal use." | |||
| 1653 | (save-excursion | 1682 | (save-excursion |
| 1654 | (save-window-excursion | 1683 | (save-window-excursion |
| 1655 | (goto-char (point-min)) | 1684 | (goto-char (point-min)) |
| 1656 | (forward-line 2) | 1685 | (if (not bookmark-bmenu-use-header-line) |
| 1686 | (forward-line bookmark-bmenu-inline-header-height)) | ||
| 1657 | (setq bookmark-bmenu-hidden-bookmarks ()) | 1687 | (setq bookmark-bmenu-hidden-bookmarks ()) |
| 1658 | (let ((inhibit-read-only t)) | 1688 | (let ((inhibit-read-only t)) |
| 1659 | (while (< (point) (point-max)) | 1689 | (while (< (point) (point-max)) |
| @@ -1681,7 +1711,8 @@ mainly for debugging, and should not be necessary in normal use." | |||
| 1681 | (with-buffer-modified-unmodified | 1711 | (with-buffer-modified-unmodified |
| 1682 | (save-excursion | 1712 | (save-excursion |
| 1683 | (goto-char (point-min)) | 1713 | (goto-char (point-min)) |
| 1684 | (forward-line 2) | 1714 | (if (not bookmark-bmenu-use-header-line) |
| 1715 | (forward-line bookmark-bmenu-inline-header-height)) | ||
| 1685 | (setq bookmark-bmenu-hidden-bookmarks | 1716 | (setq bookmark-bmenu-hidden-bookmarks |
| 1686 | (nreverse bookmark-bmenu-hidden-bookmarks)) | 1717 | (nreverse bookmark-bmenu-hidden-bookmarks)) |
| 1687 | (let ((inhibit-read-only t)) | 1718 | (let ((inhibit-read-only t)) |
| @@ -1705,9 +1736,11 @@ mainly for debugging, and should not be necessary in normal use." | |||
| 1705 | "If point is not on a bookmark line, move it to one. | 1736 | "If point is not on a bookmark line, move it to one. |
| 1706 | If before the first bookmark line, move to the first; if after the | 1737 | If before the first bookmark line, move to the first; if after the |
| 1707 | last full line, move to the last full line. The return value is undefined." | 1738 | last full line, move to the last full line. The return value is undefined." |
| 1708 | (cond ((< (count-lines (point-min) (point)) bookmark-bmenu-header-height) | 1739 | (cond ((and (not bookmark-bmenu-use-header-line) |
| 1740 | (< (count-lines (point-min) (point)) | ||
| 1741 | bookmark-bmenu-inline-header-height)) | ||
| 1709 | (goto-char (point-min)) | 1742 | (goto-char (point-min)) |
| 1710 | (forward-line bookmark-bmenu-header-height)) | 1743 | (forward-line bookmark-bmenu-inline-header-height)) |
| 1711 | ((and (bolp) (eobp)) | 1744 | ((and (bolp) (eobp)) |
| 1712 | (beginning-of-line 0)))) | 1745 | (beginning-of-line 0)))) |
| 1713 | 1746 | ||