aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2013-05-21 06:52:40 +0800
committerLeo Liu2013-05-21 06:52:40 +0800
commitb4da2cbb0d5d5d7315b13f9bf7ad445d948caac2 (patch)
tree850bd3ecabd2fdc603caf77b7622d11d3a31cab0
parent348afb155414b13983fd6f4360b3cfe6a4dc5ba9 (diff)
downloademacs-b4da2cbb0d5d5d7315b13f9bf7ad445d948caac2.tar.gz
emacs-b4da2cbb0d5d5d7315b13f9bf7ad445d948caac2.zip
Use octave-help-mode for the Octave Help buffer
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/octave.el48
2 files changed, 51 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8fcd7424401..c70f156bf45 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-05-20 Leo Liu <sdl.web@gmail.com>
2
3 * progmodes/octave.el (octave-help-mode-map)
4 (octave-help-mode-finish-hook): New variables.
5 (octave-help-mode, octave-help-mode-finish): New functions.
6 (octave-help): Use octave-help-mode.
7
12013-05-20 Glenn Morris <rgm@gnu.org> 82013-05-20 Glenn Morris <rgm@gnu.org>
2 9
3 * format-spec.el (format-spec): Allow spec chars with nil. (Bug#14420) 10 * format-spec.el (format-spec): Allow spec chars with nil. (Bug#14420)
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index df03251bbc9..4f1e6c2cc14 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -1587,14 +1587,54 @@ if ismember(exist(\"%s\"), [2 3 5 103]) print_usage(\"%s\") endif\n"
1587 (octave-help 1587 (octave-help
1588 (buffer-substring (button-start b) (button-end b))))) 1588 (buffer-substring (button-start b) (button-end b)))))
1589 1589
1590(defvar help-xref-following) 1590(defvar octave-help-mode-map
1591 (let ((map (make-sparse-keymap)))
1592 (define-key map "\M-." 'octave-find-definition)
1593 (define-key map "\C-hd" 'octave-help)
1594 map))
1595
1596(define-derived-mode octave-help-mode help-mode "OctHelp"
1597 "Major mode for displaying Octave documentation."
1598 :abbrev-table nil
1599 :syntax-table octave-mode-syntax-table
1600 (eval-and-compile (require 'help-mode))
1601 ;; Mostly stolen from `help-make-xrefs'.
1602 (let ((inhibit-read-only t))
1603 (setq-local info-lookup-mode 'octave-mode)
1604 ;; Delete extraneous newlines at the end of the docstring
1605 (goto-char (point-max))
1606 (while (and (not (bobp)) (bolp))
1607 (delete-char -1))
1608 (insert "\n")
1609 (when (or help-xref-stack help-xref-forward-stack)
1610 (insert "\n"))
1611 (when help-xref-stack
1612 (help-insert-xref-button help-back-label 'help-back
1613 (current-buffer)))
1614 (when help-xref-forward-stack
1615 (when help-xref-stack
1616 (insert "\t"))
1617 (help-insert-xref-button help-forward-label 'help-forward
1618 (current-buffer)))
1619 (when (or help-xref-stack help-xref-forward-stack)
1620 (insert "\n"))))
1621
1622(defvar octave-help-mode-finish-hook nil
1623 "Octave specific hook for `temp-buffer-show-hook'.")
1624
1625(defun octave-help-mode-finish ()
1626 (when (eq major-mode 'octave-help-mode)
1627 (run-hooks 'octave-help-mode-finish-hook)))
1628
1629(add-hook 'temp-buffer-show-hook 'octave-help-mode-finish)
1591 1630
1592(defun octave-help (fn) 1631(defun octave-help (fn)
1593 "Display the documentation of FN." 1632 "Display the documentation of FN."
1594 (interactive (list (octave-completing-read))) 1633 (interactive (list (octave-completing-read)))
1595 (inferior-octave-send-list-and-digest 1634 (inferior-octave-send-list-and-digest
1596 (list (format "help \"%s\"\n" fn))) 1635 (list (format "help \"%s\"\n" fn)))
1597 (let ((lines inferior-octave-output-list)) 1636 (let ((lines inferior-octave-output-list)
1637 (inhibit-read-only t))
1598 (when (string-match "error: \\(.*\\)$" (car lines)) 1638 (when (string-match "error: \\(.*\\)$" (car lines))
1599 (error "%s" (match-string 1 (car lines)))) 1639 (error "%s" (match-string 1 (car lines))))
1600 (with-help-window octave-help-buffer 1640 (with-help-window octave-help-buffer
@@ -1605,7 +1645,6 @@ if ismember(exist(\"%s\"), [2 3 5 103]) print_usage(\"%s\") endif\n"
1605 (let ((help-xref-following t)) 1645 (let ((help-xref-following t))
1606 (help-setup-xref (list 'octave-help fn) 1646 (help-setup-xref (list 'octave-help fn)
1607 (called-interactively-p 'interactive))) 1647 (called-interactively-p 'interactive)))
1608 (setq-local info-lookup-mode 'octave-mode)
1609 ;; Note: can be turned off by suppress_verbose_help_message. 1648 ;; Note: can be turned off by suppress_verbose_help_message.
1610 ;; 1649 ;;
1611 ;; Remove boring trailing text: Additional help for built-in functions 1650 ;; Remove boring trailing text: Additional help for built-in functions
@@ -1631,7 +1670,8 @@ if ismember(exist(\"%s\"), [2 3 5 103]) print_usage(\"%s\") endif\n"
1631 (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t) 1670 (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t)
1632 (make-text-button (match-beginning 0) 1671 (make-text-button (match-beginning 0)
1633 (match-end 0) 1672 (match-end 0)
1634 :type 'octave-help-function)))))))) 1673 :type 'octave-help-function))))
1674 (octave-help-mode)))))
1635 1675
1636(defcustom octave-source-directories nil 1676(defcustom octave-source-directories nil
1637 "A list of directories for Octave sources. 1677 "A list of directories for Octave sources.