[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 506a97a: Derive Man and WoMan modes from special-mo
From: |
Mark Oteiza |
Subject: |
[Emacs-diffs] master 506a97a: Derive Man and WoMan modes from special-mode |
Date: |
Thu, 13 Oct 2016 18:37:30 +0000 (UTC) |
branch: master
commit 506a97a58d0cff595f13e6238b59c9e8c70440d5
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>
Derive Man and WoMan modes from special-mode
* lisp/man.el (Man-mode-map): Set parent to map composed from both
button-buffer-map and special-mode-map. Remove redundant bindings.
Fix menu to refer to the quit-window command.
(Man-mode): Derive from special-mode. Fix docstring. Remove redundant
buffer-read-only binding.
(Man-quit): Remove.
* lisp/woman.el (woman-really-find-file): Use setq-local.
(woman-mode-map): Refer to woman-mode in docstring.
(woman-mode): Derive from special-mode. Document woman-mode-map in
docstring. Use setq-local where possible; imenu-generic-expression is
already buffer-local.
(woman-negative-vertical-space): Replace unused binding with _.
---
lisp/man.el | 26 ++++++--------------------
lisp/woman.el | 25 ++++++++++---------------
2 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/lisp/man.el b/lisp/man.el
index 0f3c4ba..82691f5 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -432,29 +432,23 @@ Otherwise, the value is whatever the function
(defvar Man-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
- (set-keymap-parent map button-buffer-map)
+ (set-keymap-parent map
+ (make-composed-keymap button-buffer-map special-mode-map))
- (define-key map [?\S-\ ] 'scroll-down-command)
- (define-key map " " 'scroll-up-command)
- (define-key map "\177" 'scroll-down-command)
(define-key map "n" 'Man-next-section)
(define-key map "p" 'Man-previous-section)
(define-key map "\en" 'Man-next-manpage)
(define-key map "\ep" 'Man-previous-manpage)
- (define-key map ">" 'end-of-buffer)
- (define-key map "<" 'beginning-of-buffer)
(define-key map "." 'beginning-of-buffer)
(define-key map "r" 'Man-follow-manual-reference)
(define-key map "g" 'Man-goto-section)
(define-key map "s" 'Man-goto-see-also-section)
(define-key map "k" 'Man-kill)
- (define-key map "q" 'Man-quit)
(define-key map "u" 'Man-update-manpage)
(define-key map "m" 'man)
;; Not all the man references get buttons currently. The text in the
;; manual page can contain references to other man pages
(define-key map "\r" 'man-follow)
- (define-key map "?" 'describe-mode)
(easy-menu-define nil map
"`Man-mode' menu."
@@ -476,7 +470,7 @@ Otherwise, the value is whatever the function
"--"
["Man..." man t]
["Kill Buffer" Man-kill t]
- ["Quit" Man-quit t]))
+ ["Quit" quit-window t]))
map)
"Keymap for Man mode.")
@@ -1474,9 +1468,7 @@ manpage command."
(defvar bookmark-make-record-function)
-(put 'Man-mode 'mode-class 'special)
-
-(define-derived-mode Man-mode fundamental-mode "Man"
+(define-derived-mode Man-mode special-mode "Man"
"A mode for browsing Un*x manual pages.
The following man commands are available in the buffer. Try
@@ -1490,7 +1482,7 @@ The following man commands are available in the buffer.
Try
\\[Man-previous-section] Jump to previous manpage section.
\\[Man-goto-section] Go to a manpage section.
\\[Man-goto-see-also-section] Jumps to the SEE ALSO manpage section.
-\\[Man-quit] Deletes the manpage window, bury its buffer.
+\\[quit-window] Deletes the manpage window, bury its buffer.
\\[Man-kill] Deletes the manpage window, kill its buffer.
\\[describe-mode] Prints this help text.
@@ -1517,8 +1509,7 @@ The following key bindings are currently in effect in the
buffer:
mode-line-buffer-identification
(list (default-value 'mode-line-buffer-identification)
" {" 'Man-page-mode-string "}")
- truncate-lines t
- buffer-read-only t)
+ truncate-lines t)
(buffer-disable-undo)
(auto-fill-mode -1)
(setq imenu-generic-expression (list (list nil Man-heading-regexp 0)))
@@ -1794,11 +1785,6 @@ Specify which REFERENCE to use; default is based on word
at point."
(interactive)
(quit-window t))
-(defun Man-quit ()
- "Bury the buffer containing the manpage."
- (interactive)
- (quit-window))
-
(defun Man-goto-page (page &optional noerror)
"Go to the manual page on page PAGE."
(interactive
diff --git a/lisp/woman.el b/lisp/woman.el
index 3822ce6..45b03a9 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1657,7 +1657,7 @@ Do not call directly!"
(woman-insert-file-contents filename compressed)
;; Set buffer's default directory to that of the file.
(setq default-directory (file-name-directory filename))
- (set (make-local-variable 'backup-inhibited) t)
+ (setq-local backup-inhibited t)
(set-visited-file-name "")
(woman-process-buffer)))
@@ -1780,7 +1780,7 @@ Leave point at end of new text. Return length of
inserted text."
(define-key map [remap man] 'woman)
(define-key map [remap man-follow] 'woman-follow)
map)
- "Keymap for woman mode.")
+ "Keymap for `woman-mode'.")
(defun woman-follow (topic)
"Get a Un*x manual page of the item under point and put it in a buffer."
@@ -1872,15 +1872,15 @@ Argument EVENT is the invoking mouse event."
(woman-reformat-last-file))
(defvar bookmark-make-record-function)
-(put 'woman-mode 'mode-class 'special)
-(defun woman-mode ()
+(define-derived-mode woman-mode special-mode "WoMan"
"Turn on (most of) Man mode to browse a buffer formatted by WoMan.
WoMan is an ELisp emulation of much of the functionality of the Emacs
`man' command running the standard UN*X man and ?roff programs.
WoMan author: address@hidden
WoMan version: see `woman-version'.
-See `Man-mode' for additional details."
+See `Man-mode' for additional details.
+\\{woman-mode-map}"
(let ((Man-build-page-list (symbol-function 'Man-build-page-list))
(Man-strip-page-headers (symbol-function 'Man-strip-page-headers))
(Man-unindent (symbol-function 'Man-unindent))
@@ -1905,13 +1905,10 @@ See `Man-mode' for additional details."
(kill-local-variable 'mode-line-buffer-identification)
(use-local-map woman-mode-map)
;; Imenu support:
- (set (make-local-variable 'imenu-generic-expression)
- ;; `make-local-variable' in case imenu not yet loaded!
- woman-imenu-generic-expression)
- (set (make-local-variable 'imenu-space-replacement) " ")
+ (setq imenu-generic-expression woman-imenu-generic-expression)
+ (setq-local imenu-space-replacement " ")
;; Bookmark support.
- (set (make-local-variable 'bookmark-make-record-function)
- 'woman-bookmark-make-record)
+ (setq-local bookmark-make-record-function 'woman-bookmark-make-record)
;; For reformat ...
;; necessary when reformatting a file in its old buffer:
(setq imenu--last-menubar-index-alist nil)
@@ -1919,9 +1916,7 @@ See `Man-mode' for additional details."
(setq woman-imenu-done nil)
(if woman-imenu (woman-imenu))
(let ((inhibit-read-only t))
- (Man-highlight-references 'WoMan-xref-man-page))
- (set-buffer-modified-p nil)
- (run-mode-hooks 'woman-mode-hook))
+ (Man-highlight-references 'WoMan-xref-man-page)))
(defun woman-imenu (&optional redraw)
"Add a \"Contents\" menu to the menubar.
@@ -3884,7 +3879,7 @@ Leave 1 blank line. Format paragraphs upto TO."
((eq c ?\t) ; skip
(if (eq (following-char) ?\t)
(forward-char) ; both tabs, just skip
- (dotimes (i woman-tab-width)
+ (dotimes (_ woman-tab-width)
(if (eolp)
(insert ?\s) ; extend line
(forward-char)) ; skip
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 506a97a: Derive Man and WoMan modes from special-mode,
Mark Oteiza <=