Commit d8c201f5 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(outline-minor-mode): Use define-minor-mode.

(outline-mode): Use define-derived-mode.
parent be5e3be3
2000-09-28 Stefan Monnier <monnier@cs.yale.edu>
* textmodes/outline.el (outline-minor-mode): Use define-minor-mode.
(outline-mode): Use define-derived-mode.
* progmodes/perl-mode.el (perl-mode):
* progmodes/awk-mode.el (awk-mode):
* progmodes/asm-mode.el (asm-mode):
Don't gratuitously override the default for comment-column.
* emacs-lisp/lisp.el (lisp-complete-symbol):
Distinguish the let-binding case from the funcall case.
(forward-sexp-function): New variable.
(forward-sexp): Use it.
* emacs-lisp/easy-mmode.el (easy-mmode-define-keymap): Autoload.
(easy-mmode-defmap): Remove the now useless autoload.
* time.el (display-time-mode): Use define-minor-mode.
* subr.el (add-minor-mode): Don't eval NAME.
Don't depend on the presence of TOGGLE-FUN for any special behavior.
Use if rather than cond.
* simple.el (read-expression-map): Define more properly.
(comment-indent-hook): Remove.
(string-to-syntax): Bug fix.
* pcvs.el (cvs-ediff-exit-hook): Kill buffer before window.
(cvs-ediff-diff): Fix typo.
(cvs-revert-if-needed): Don't bother preserving read-only.
* paren.el (show-paren-mode): Use define-minor-mode.
* jka-compr.el (auto-compression-mode): Use define-minor-mode.
(toggle-auto-compression): Remove.
(jka-compr-build-file-regexp): Remove useless grouping.
* diff-mode.el (diff-mode-map, diff-minor-mode-prefix):
Avoid user-reserved bindings.
(diff-mode, diff-minor-mode): Drop make-local-hook (done by add-hook).
(diff-header-face): Revert to grey85.
* cvs-status.el (cvs-status-entry-leader-re): Minor fix.
* complete.el (partial-completion-mode) <defcustom>: Remove.
(partial-completion-mode): Use define-minor-mode.
(PC-do-completion): Understand `completion-auto-help = delay'
to mean to popup the completion buffer only the second time.
(PC-include-file-all-completions, PC-include-file-all-completions)
(PC-include-file-all-completions): Don't quote lambda.
* comint.el (comint-mode-hook): Docstring fix.
(comint-mode): Use define-derived-mode.
(comint-mode-map): Remove obsolete comment.
(make-comint): Minor stylistic change.
(comint-insert-clicked-input): Be more careful to find the overlay.
Use this-command-keys rather than hardcoding mouse-2.
* font-lock.el: Replace confusing (,@ with ,
(tex-font-lock-keywords-1, tex-font-lock-keywords-2):
Don't use regexp-opt-depth. Spice up the regexp for args.
Don't distinguish between cmds that can take an opt arg or not.
Use `append' and `prepend' rather than `keep'.
* textmodes/tex-mode.el (latex-imenu-indent-string): Add a space.
(latex-outline-regexp): New var.
(latex-outline-level): New fun.
(latex-section-alist): New var.
(latex-imenu-create-index): Use it. Use `push' as well.
(tex-shell-map): Initialize it properly.
(tex-mode): Minor stylistic change.
(plain-tex-mode): Use define-derived-mode.
(latex-mode): Use define-derived-mode.
Construct the paragraph regexps in a more readable way.
Set the buffer-local outline-{level,regexp} vars.
(slitex-mode): Derive from latex-mode.
(tex-common-initialization): Don't kill-all-vars anymore.
Add setting for comment-add and font-lock-defaults.
(tex-start-shell): Use with-current-buffer and don't re-init keymap.
(tex-main-file): New fun. Obey TeX-master as well and remove `.tex'.
(tex-start-tex): New arg DIR (and send a chdir command for it).
Also display the shell buffer and save it in tex-last-buffer-texed.
(tex-region): Use expand-file-name rather than concat.
Remove code made useless by changes in tex-start-tex.
(tex-file): Use tex-main-file and adapt to new tex-start-tex.
* map-ynp.el (map-y-or-n-p): Fix missing backquotes.
2000-09-28 Dave Love <fx@gnu.org> 2000-09-28 Dave Love <fx@gnu.org>
* eshell/eshell.el (eshell) <defgroup>: Add :version. * eshell/eshell.el (eshell) <defgroup>: Add :version.
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
;; An outline can be `abstracted' to show headers at any given level, ;; An outline can be `abstracted' to show headers at any given level,
;; with all stuff below hidden. See the Emacs manual for details. ;; with all stuff below hidden. See the Emacs manual for details.
;;; Todo:
;; - subtree-terminators
;;; Code: ;;; Code:
(defgroup outlines nil (defgroup outlines nil
...@@ -140,15 +144,6 @@ in the file it applies to." ...@@ -140,15 +144,6 @@ in the file it applies to."
(define-key outline-mode-map "\C-c" outline-mode-prefix-map) (define-key outline-mode-map "\C-c" outline-mode-prefix-map)
(define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map))
(defcustom outline-minor-mode nil
"Non-nil if using Outline mode as a minor mode of some other mode."
:type 'boolean
:group 'outlines)
(make-variable-buffer-local 'outline-minor-mode)
(or (assq 'outline-minor-mode minor-mode-alist)
(setq minor-mode-alist (append minor-mode-alist
(list '(outline-minor-mode " Outl")))))
(defvar outline-font-lock-keywords (defvar outline-font-lock-keywords
'(;; '(;;
;; Highlight headings according to the level. ;; Highlight headings according to the level.
...@@ -181,7 +176,7 @@ in the file it applies to." ...@@ -181,7 +176,7 @@ in the file it applies to."
"Normal hook to be run after outline visibility changes.") "Normal hook to be run after outline visibility changes.")
;;;###autoload ;;;###autoload
(defun outline-mode () (define-derived-mode outline-mode text-mode "Outline"
"Set major mode for editing outlines with selective display. "Set major mode for editing outlines with selective display.
Headings are lines which start with asterisks: one for major headings, Headings are lines which start with asterisks: one for major headings,
two for subheadings, etc. Lines not starting with asterisks are body lines. two for subheadings, etc. Lines not starting with asterisks are body lines.
...@@ -220,34 +215,21 @@ beginning of the line. The longer the match, the deeper the level. ...@@ -220,34 +215,21 @@ beginning of the line. The longer the match, the deeper the level.
Turning on outline mode calls the value of `text-mode-hook' and then of Turning on outline mode calls the value of `text-mode-hook' and then of
`outline-mode-hook', if they are non-nil." `outline-mode-hook', if they are non-nil."
(interactive)
(kill-all-local-variables)
(use-local-map outline-mode-map)
(setq mode-name "Outline")
(setq major-mode 'outline-mode)
(define-abbrev-table 'text-mode-abbrev-table ())
(setq local-abbrev-table text-mode-abbrev-table)
(set-syntax-table text-mode-syntax-table)
(make-local-variable 'line-move-ignore-invisible) (make-local-variable 'line-move-ignore-invisible)
(setq line-move-ignore-invisible t) (setq line-move-ignore-invisible t)
;; Cause use of ellipses for invisible text. ;; Cause use of ellipses for invisible text.
(add-to-invisibility-spec '(outline . t)) (add-to-invisibility-spec '(outline . t))
(make-local-variable 'paragraph-start) (set (make-local-variable 'paragraph-start)
(setq paragraph-start (concat paragraph-start "\\|\\(" (concat paragraph-start "\\|\\(" outline-regexp "\\)"))
outline-regexp "\\)"))
;; Inhibit auto-filling of header lines. ;; Inhibit auto-filling of header lines.
(make-local-variable 'auto-fill-inhibit-regexp) (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp)
(setq auto-fill-inhibit-regexp outline-regexp) (set (make-local-variable 'paragraph-separate)
(make-local-variable 'paragraph-separate) (concat paragraph-separate "\\|\\(" outline-regexp "\\)"))
(setq paragraph-separate (concat paragraph-separate "\\|\\(" (set (make-local-variable 'font-lock-defaults)
outline-regexp "\\)")) '(outline-font-lock-keywords t))
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(outline-font-lock-keywords t))
(make-local-variable 'change-major-mode-hook)
(setq imenu-generic-expression (setq imenu-generic-expression
(list (list nil (concat outline-regexp ".*$") 0))) (list (list nil (concat outline-regexp ".*$") 0)))
(add-hook 'change-major-mode-hook 'show-all) (add-hook 'change-major-mode-hook 'show-all nil t))
(run-hooks 'text-mode-hook 'outline-mode-hook))
(defcustom outline-minor-mode-prefix "\C-c@" (defcustom outline-minor-mode-prefix "\C-c@"
"*Prefix key to use for Outline commands in Outline minor mode. "*Prefix key to use for Outline commands in Outline minor mode.
...@@ -256,48 +238,28 @@ After that, changing the prefix key requires manipulating keymaps." ...@@ -256,48 +238,28 @@ After that, changing the prefix key requires manipulating keymaps."
:type 'string :type 'string
:group 'outlines) :group 'outlines)
(defvar outline-minor-mode-map nil)
(if outline-minor-mode-map
nil
(setq outline-minor-mode-map (make-sparse-keymap))
(define-key outline-minor-mode-map [menu-bar]
outline-mode-menu-bar-map)
(define-key outline-minor-mode-map outline-minor-mode-prefix
outline-mode-prefix-map))
(or (assq 'outline-minor-mode minor-mode-map-alist)
(setq minor-mode-map-alist
(cons (cons 'outline-minor-mode outline-minor-mode-map)
minor-mode-map-alist)))
;;;###autoload ;;;###autoload
(defun outline-minor-mode (&optional arg) (define-minor-mode outline-minor-mode
"Toggle Outline minor mode. "Toggle Outline minor mode.
With arg, turn Outline minor mode on if arg is positive, off otherwise. With arg, turn Outline minor mode on if arg is positive, off otherwise.
See the command `outline-mode' for more information on this mode." See the command `outline-mode' for more information on this mode."
(interactive "P") nil " Outl" (list (cons [menu-bar] outline-mode-menu-bar-map)
(setq outline-minor-mode (cons outline-minor-mode-prefix outline-mode-prefix-map))
(if (null arg) (not outline-minor-mode)
(> (prefix-numeric-value arg) 0)))
(if outline-minor-mode (if outline-minor-mode
(progn (progn
(make-local-hook 'change-major-mode-hook)
;; Turn off this mode if we change major modes. ;; Turn off this mode if we change major modes.
(add-hook 'change-major-mode-hook (add-hook 'change-major-mode-hook
(lambda () (outline-minor-mode -1)) (lambda () (outline-minor-mode -1))
nil t) nil t)
(make-local-variable 'line-move-ignore-invisible) (set (make-local-variable 'line-move-ignore-invisible) t)
(setq line-move-ignore-invisible t)
;; Cause use of ellipses for invisible text. ;; Cause use of ellipses for invisible text.
(add-to-invisibility-spec '(outline . t)) (add-to-invisibility-spec '(outline . t)))
(run-hooks 'outline-minor-mode-hook))
(setq line-move-ignore-invisible nil) (setq line-move-ignore-invisible nil)
;; Cause use of ellipses for invisible text. ;; Cause use of ellipses for invisible text.
(remove-from-invisibility-spec '(outline . t))) (remove-from-invisibility-spec '(outline . t)))
;; When turning off outline mode, get rid of any outline hiding. ;; When turning off outline mode, get rid of any outline hiding.
(or outline-minor-mode (or outline-minor-mode
(show-all)) (show-all)))
(force-mode-line-update))
(defcustom outline-level 'outline-level (defcustom outline-level 'outline-level
"*Function of no args to compute a header's nesting level in an outline. "*Function of no args to compute a header's nesting level in an outline.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment