emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112647: Use octave-help-mode for the


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112647: Use octave-help-mode for the Octave Help buffer
Date: Tue, 21 May 2013 06:52:40 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112647
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Tue 2013-05-21 06:52:40 +0800
message:
  Use octave-help-mode for the Octave Help buffer
modified:
  lisp/ChangeLog
  lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-20 07:45:58 +0000
+++ b/lisp/ChangeLog    2013-05-20 22:52:40 +0000
@@ -1,3 +1,10 @@
+2013-05-20  Leo Liu  <address@hidden>
+
+       * progmodes/octave.el (octave-help-mode-map)
+       (octave-help-mode-finish-hook): New variables.
+       (octave-help-mode, octave-help-mode-finish): New functions.
+       (octave-help): Use octave-help-mode.
+
 2013-05-20  Glenn Morris  <address@hidden>
 
        * format-spec.el (format-spec): Allow spec chars with nil.  (Bug#14420)

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-05-18 03:17:35 +0000
+++ b/lisp/progmodes/octave.el  2013-05-20 22:52:40 +0000
@@ -1587,14 +1587,54 @@
             (octave-help
              (buffer-substring (button-start b) (button-end b)))))
 
-(defvar help-xref-following)
+(defvar octave-help-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\M-." 'octave-find-definition)
+    (define-key map "\C-hd" 'octave-help)
+    map))
+
+(define-derived-mode octave-help-mode help-mode "OctHelp"
+  "Major mode for displaying Octave documentation."
+  :abbrev-table nil
+  :syntax-table octave-mode-syntax-table
+  (eval-and-compile (require 'help-mode))
+  ;; Mostly stolen from `help-make-xrefs'.
+  (let ((inhibit-read-only t))
+    (setq-local info-lookup-mode 'octave-mode)
+    ;; Delete extraneous newlines at the end of the docstring
+    (goto-char (point-max))
+    (while (and (not (bobp)) (bolp))
+      (delete-char -1))
+    (insert "\n")
+    (when (or help-xref-stack help-xref-forward-stack)
+      (insert "\n"))
+    (when help-xref-stack
+      (help-insert-xref-button help-back-label 'help-back
+                               (current-buffer)))
+    (when help-xref-forward-stack
+      (when help-xref-stack
+        (insert "\t"))
+      (help-insert-xref-button help-forward-label 'help-forward
+                               (current-buffer)))
+    (when (or help-xref-stack help-xref-forward-stack)
+      (insert "\n"))))
+
+(defvar octave-help-mode-finish-hook nil
+  "Octave specific hook for `temp-buffer-show-hook'.")
+
+(defun octave-help-mode-finish ()
+  (when (eq major-mode 'octave-help-mode)
+    (run-hooks 'octave-help-mode-finish-hook)))
+
+(add-hook 'temp-buffer-show-hook 'octave-help-mode-finish)
 
 (defun octave-help (fn)
   "Display the documentation of FN."
   (interactive (list (octave-completing-read)))
   (inferior-octave-send-list-and-digest
    (list (format "help \"%s\"\n" fn)))
-  (let ((lines inferior-octave-output-list))
+  (let ((lines inferior-octave-output-list)
+        (inhibit-read-only t))
     (when (string-match "error: \\(.*\\)$" (car lines))
       (error "%s" (match-string 1 (car lines))))
     (with-help-window octave-help-buffer
@@ -1605,7 +1645,6 @@
         (let ((help-xref-following t))
           (help-setup-xref (list 'octave-help fn)
                            (called-interactively-p 'interactive)))
-        (setq-local info-lookup-mode 'octave-mode)
         ;; Note: can be turned off by suppress_verbose_help_message.
         ;;
         ;; Remove boring trailing text: Additional help for built-in functions
@@ -1631,7 +1670,8 @@
             (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t)
               (make-text-button (match-beginning 0)
                                 (match-end 0)
-                                :type 'octave-help-function))))))))
+                                :type 'octave-help-function))))
+        (octave-help-mode)))))
 
 (defcustom octave-source-directories nil
   "A list of directories for Octave sources.


reply via email to

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