Mercurial > emacs
annotate lisp/textmodes/ooutline.el @ 26088:b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
* Makefile.in (emacs): Set the LC_ALL environment variable to "C"
when dumping, so that the dumped Emacs doesn't have stray locale info.
(dired.o): Depend on systime.h.
(editfns.o): Depend on coding.h.
* alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c,
dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c,
keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c,
unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c,
w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c:
Include <config.h> before any system include files.
* alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c,
fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c,
m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c,
xmenu.c, xterm.c:
Do not include <stdlib.h>, as <config.h> does this now.
* callproc.c (Fcall_process):
Synchronize messages locale before invoking strerror.
Decode resulting string with locale-coding-system.
* coding.c (Vlocale_coding_system): New var.
(syms_of_coding): Adjust to above change.
(emacs_strerror): New function.
* coding.h (emacs_strerror, Vlocale_coding_system): New decls.
* config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING,
HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN,
HAVE_STRSIGNAL): New macros.
(BITS_PER_LONG): Default to 64 if _LP64 is defined.
<stdlib.h>: Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't.
* dired.c: Include "systime.h".
(Ffile_attributes): Do not cast s.st_size to int; this loses
information if int is 32 bits but st_size and EMACS_INT are larger.
Treat large device numbers like large inode numbers.
* dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available.
* editfns.c: Include coding.h.
(emacs_strftime): Remove decl.
(emacs_strftimeu): New decl.
(emacs_memftimeu): Renamed from emacs_memftime; new arg UT.
Use emacs_strftimeu instead of emacs_strftime.
(Fformat_time_string): Convert format string using
Vlocale_coding_system, and convert result back. Synchronize time
locale before invoking lower level function. Invoke
emacs_memftimeu, passing ut, instead of emacs_memftime.
* emacs.c: Include <locale.h> if HAVE_SETLOCALE is defined.
(Vmessages_locale, Vprevious_messages_locale, Vtime_locale,
Vprevious_time_locale): New variables.
(main): Invoke setlocale early, so that initial error messages are
localized properly. But skip locale-setting if LC_ALL is "C".
Fix up locale when it's safe to do so.
(fixup_locale): Moved here from xterm.c.
(synchronize_locale, synchronize_time_locale,
synchronize_messages_locale): New functions.
(syms_of_emacs): Accommodate above changes.
* fileio.c (report_file_error): Convert strerror output according
to Vlocale_coding_system.
(Finsert_file_contents): Check for arithmetic overflow in
computations that depend on file size. Report IO errors
with emacs_strerror, not strerror.
* fns.c (Fgethash): Declare dflt parameter.
* gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H
is defined; that's config.h's job.
* lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64,
default these values to long, BITS_PER_LONG, and unsigned long.
(VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT.
(PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int.
(code_convert_string_norecord, fixup_locale,
synchronize_messages_locale, synchronize_time_locale,
emacs_open, emacs_close, emacs_read, emacs_write): New decls.
All Emacs callers of open, close, read, write changed to use
emacs_open, emacs_close, emacs_read, emacs_write.
* lread.c (file_offset, file_tell): New macros. All uses of ftell
changed to file_tell.
(saved_doc_string_position, prev_saved_doc_string_position): Now
of type file_offset.
(init_lread): Do not fix locale here; fixup_locale now does this.
* m/amdahl.h, s/usg5-4.h:
(NSIG): Remove.
(NSIG_MINIMUM): New macro.
* m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h,
m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h,
s/umips.h, s/usg5-4.h:
(SIGIO): Do not undef.
(BROKEN_SIGIO): New macro.
* m/ustation.h:
(SIGTSTP): Do not undef.
(BROKEN_SIGTSTP): New macro.
* s/gnu-linux.h:
(SIGPOLL, SIGURG): Do not undef.
(BROKEN_SIGPOLL, BROKEN_SIGURG): New macros.
* s/ptx4.h:
(SIGINFO): Do not undef.
(BROKEN_SIGINFO): New macros.
* m/delta.h, s/ptx.h, s/template.h: Doc fix.
* mktime.c, strftime.c: Update to glibc 2.1.2 version, with
some Emacs-related changes merged.
* print.c (float_to_string): Prepend "-" to representation of a
NaN if the NaN is negative.
* process.c (sys_siglist): Omit if HAVE_STRSIGNAL.
(wait_reading_process_input): Use emacs_strerror, not strerror.
* process.c (status_message, sigchld_handler): Synchronize locale,
then use strsignal istead of sys_siglist.
* w32proc.c (sys_wait): Likewise.
* s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h,
s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h,
s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h,
s/usg5-2.h, s/usg5-3.h, s/xenix.h:
(open, close, read, write, INTERRUPTIBLE_OPEN,
INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove.
* s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros.
* sysdep.c (sys_read, sys_write, read, write, sys_close, close,
sys_open, open): Remove.
(emacs_open, emacs_close, emacs_read, emacs_write): Always define;
the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO
macros are no longer used.
(emacs_open): Renamed from sys_open. Merge BSD4_1 version.
(emacs_close): Renamed from sys_close.
(emacs_read): Renamed from sys_read.
(emacs_write): Renamed from sys_write.
(sys_siglist): Do not declare if HAVE_STRSIGNAL.
(dup2): Do not print error on failure; the real dup2 doesn't.
(strsignal): New function, defined if !HAVE_STRSIGNAL.
* syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO
is defined.
(SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise.
(NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM.
(strsignal): Declare if !HAVE_STRSIGNAL.
* unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros.
(ElfW): Define in terms of ElfExpandBitsW.
* w32proc.c (sys_siglist): Remove decl.
* xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply
with ANSI C.
(display_string): Declare face_string_pos arg.
* xfns.c (Fx_show_tip): Declare timeout param.
* xterm.c: No need to include locale.h.
(x_alloc_lighter_color, x_setup_relief_color):
Pass arg as double, not float, for compatibility with ANSI C.
(fixup_locale): Move to emacs.c.
(x_term_init): Do not setlocale or fixup locale; the main program
does this now.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Tue, 19 Oct 1999 07:25:11 +0000 |
parents | 018d8cb92e90 |
children | 53ad7abcccf8 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; outline.el --- outline mode commands for Emacs |
14169 | 2 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
3 ;; Copyright (C) 1986, 1993, 1994, 1997 Free Software Foundation, Inc. |
845 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
5 ;; Maintainer: FSF |
11455 | 6 ;; Keywords: outlines |
234 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
234 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
234 | 24 |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 ;; This package is a major mode for editing outline-format documents. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; An outline can be `abstracted' to show headers at any given level, |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 ;; with all stuff below hidden. See the Emacs manual for details. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
31 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
32 |
234 | 33 ;; Jan '86, Some new features added by Peter Desnoyers and rewritten by RMS. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
34 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
35 (defgroup outlines nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
36 "Support for hierarchical outlining" |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
37 :prefix "outline-" |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
38 :group 'editing) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
39 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
40 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
41 (defcustom outline-regexp nil |
234 | 42 "*Regular expression to match the beginning of a heading. |
43 Any line whose beginning matches this regexp is considered to start a heading. | |
44 The recommended way to set this is with a Local Variables: list | |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
45 in the file it applies to. See also outline-heading-end-regexp." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
46 :type '(choice regexp (const nil)) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
47 :group 'outlines) |
6274
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
48 |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
49 ;; Can't initialize this in the defvar above -- some major modes have |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
50 ;; already assigned a local value to it. |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
51 (or (default-value 'outline-regexp) |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
52 (setq-default outline-regexp "[*\^L]+")) |
234 | 53 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
54 (defcustom outline-heading-end-regexp "[\n\^M]" |
234 | 55 "*Regular expression to match the end of a heading line. |
56 You can assume that point is at the beginning of a heading when this | |
57 regexp is searched for. The heading ends at the end of the match. | |
58 The recommended way to set this is with a \"Local Variables:\" list | |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
59 in the file it applies to." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
60 :type 'regexp |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
61 :group 'outlines) |
234 | 62 |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
63 (defvar outline-mode-prefix-map nil) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
64 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
65 (if outline-mode-prefix-map |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
66 nil |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
67 (setq outline-mode-prefix-map (make-sparse-keymap)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
68 (define-key outline-mode-prefix-map "\C-n" 'outline-next-visible-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
69 (define-key outline-mode-prefix-map "\C-p" 'outline-previous-visible-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
70 (define-key outline-mode-prefix-map "\C-i" 'show-children) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
71 (define-key outline-mode-prefix-map "\C-s" 'show-subtree) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
72 (define-key outline-mode-prefix-map "\C-d" 'hide-subtree) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
73 (define-key outline-mode-prefix-map "\C-u" 'outline-up-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
74 (define-key outline-mode-prefix-map "\C-f" 'outline-forward-same-level) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
75 (define-key outline-mode-prefix-map "\C-b" 'outline-backward-same-level) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
76 (define-key outline-mode-prefix-map "\C-t" 'hide-body) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
77 (define-key outline-mode-prefix-map "\C-a" 'show-all) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
78 (define-key outline-mode-prefix-map "\C-c" 'hide-entry) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
79 (define-key outline-mode-prefix-map "\C-e" 'show-entry) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
80 (define-key outline-mode-prefix-map "\C-l" 'hide-leaves) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
81 (define-key outline-mode-prefix-map "\C-k" 'show-branches) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
82 (define-key outline-mode-prefix-map "\C-q" 'hide-sublevels) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
83 (define-key outline-mode-prefix-map "\C-o" 'hide-other)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
84 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
85 (defvar outline-mode-menu-bar-map nil) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
86 (if outline-mode-menu-bar-map |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
87 nil |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
88 (setq outline-mode-menu-bar-map (make-sparse-keymap)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
89 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
90 (define-key outline-mode-menu-bar-map [hide] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
91 (cons "Hide" (make-sparse-keymap "Hide"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
92 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
93 (define-key outline-mode-menu-bar-map [hide hide-other] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
94 '("Hide Other" . hide-other)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
95 (define-key outline-mode-menu-bar-map [hide hide-sublevels] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
96 '("Hide Sublevels" . hide-sublevels)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
97 (define-key outline-mode-menu-bar-map [hide hide-subtree] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
98 '("Hide Subtree" . hide-subtree)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
99 (define-key outline-mode-menu-bar-map [hide hide-entry] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
100 '("Hide Entry" . hide-entry)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
101 (define-key outline-mode-menu-bar-map [hide hide-body] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
102 '("Hide Body" . hide-body)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
103 (define-key outline-mode-menu-bar-map [hide hide-leaves] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
104 '("Hide Leaves" . hide-leaves)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
105 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
106 (define-key outline-mode-menu-bar-map [show] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
107 (cons "Show" (make-sparse-keymap "Show"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
108 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
109 (define-key outline-mode-menu-bar-map [show show-subtree] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
110 '("Show Subtree" . show-subtree)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
111 (define-key outline-mode-menu-bar-map [show show-children] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
112 '("Show Children" . show-children)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
113 (define-key outline-mode-menu-bar-map [show show-branches] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
114 '("Show Branches" . show-branches)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
115 (define-key outline-mode-menu-bar-map [show show-entry] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
116 '("Show Entry" . show-entry)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
117 (define-key outline-mode-menu-bar-map [show show-all] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
118 '("Show All" . show-all)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
119 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
120 (define-key outline-mode-menu-bar-map [headings] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
121 (cons "Headings" (make-sparse-keymap "Headings"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
122 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
123 (define-key outline-mode-menu-bar-map [headings outline-backward-same-level] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
124 '("Previous Same Level" . outline-backward-same-level)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
125 (define-key outline-mode-menu-bar-map [headings outline-forward-same-level] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
126 '("Next Same Level" . outline-forward-same-level)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
127 (define-key outline-mode-menu-bar-map [headings outline-previous-visible-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
128 '("Previous" . outline-previous-visible-heading)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
129 (define-key outline-mode-menu-bar-map [headings outline-next-visible-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
130 '("Next" . outline-next-visible-heading)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
131 (define-key outline-mode-menu-bar-map [headings outline-up-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
132 '("Up" . outline-up-heading))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
133 |
234 | 134 (defvar outline-mode-map nil "") |
135 | |
136 (if outline-mode-map | |
137 nil | |
138 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map)) | |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
139 (define-key outline-mode-map "\C-c" outline-mode-prefix-map) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
140 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) |
234 | 141 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
142 (defcustom outline-minor-mode nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
143 "Non-nil if using Outline mode as a minor mode of some other mode." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
144 :type 'boolean |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
145 :group 'outlines) |
2934
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
146 (make-variable-buffer-local 'outline-minor-mode) |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
147 (put 'outline-minor-mode 'permanent-local t) |
5693
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
148 (or (assq 'outline-minor-mode minor-mode-alist) |
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
149 (setq minor-mode-alist (append minor-mode-alist |
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
150 (list '(outline-minor-mode " Outl"))))) |
234 | 151 |
9378
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
152 (defvar outline-font-lock-keywords |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
153 '(;; Highlight headings according to the level. |
16147
15cb7a0da3e0
(outline-font-lock-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
154 ("^\\([*]+\\)[ \t]*\\([^\n\r]+\\)?[ \t]*[\n\r]" |
9378
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
155 (1 font-lock-string-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
156 (2 (let ((len (- (match-end 1) (match-beginning 1)))) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
157 (or (cdr (assq len '((1 . font-lock-function-name-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
158 (2 . font-lock-keyword-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
159 (3 . font-lock-comment-face)))) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
160 font-lock-variable-name-face)) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
161 nil t)) |
14040 | 162 ;; Highlight citations of the form [1] and [Mar94]. |
9378
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
163 ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face)) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
164 "Additional expressions to highlight in Outline mode.") |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
165 |
234 | 166 (defun outline-mode () |
167 "Set major mode for editing outlines with selective display. | |
168 Headings are lines which start with asterisks: one for major headings, | |
169 two for subheadings, etc. Lines not starting with asterisks are body lines. | |
170 | |
171 Body text or subheadings under a heading can be made temporarily | |
172 invisible, or visible again. Invisible lines are attached to the end | |
173 of the heading, so they move with it, if the line is killed and yanked | |
174 back. A heading with text hidden under it is marked with an ellipsis (...). | |
175 | |
176 Commands:\\<outline-mode-map> | |
177 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings | |
178 \\[outline-previous-visible-heading] outline-previous-visible-heading | |
179 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings | |
180 \\[outline-backward-same-level] outline-backward-same-level | |
181 \\[outline-up-heading] outline-up-heading move from subheading to heading | |
182 | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
183 \\[hide-body] make all text invisible (not headings). |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
184 \\[show-all] make everything in buffer visible. |
234 | 185 |
186 The remaining commands are used when point is on a heading line. | |
187 They apply to some of the body or subheadings of that heading. | |
188 \\[hide-subtree] hide-subtree make body and subheadings invisible. | |
189 \\[show-subtree] show-subtree make body and subheadings visible. | |
190 \\[show-children] show-children make direct subheadings visible. | |
191 No effect on body, or subheadings 2 or more levels down. | |
192 With arg N, affects subheadings N levels down. | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
193 \\[hide-entry] make immediately following body invisible. |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
194 \\[show-entry] make it visible. |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
195 \\[hide-leaves] make body under heading and under its subheadings invisible. |
234 | 196 The subheadings remain visible. |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
197 \\[show-branches] make all subheadings at all levels visible. |
234 | 198 |
199 The variable `outline-regexp' can be changed to control what is a heading. | |
200 A line is a heading if `outline-regexp' matches something at the | |
201 beginning of the line. The longer the match, the deeper the level. | |
202 | |
203 Turning on outline mode calls the value of `text-mode-hook' and then of | |
204 `outline-mode-hook', if they are non-nil." | |
205 (interactive) | |
206 (kill-all-local-variables) | |
207 (setq selective-display t) | |
208 (use-local-map outline-mode-map) | |
209 (setq mode-name "Outline") | |
210 (setq major-mode 'outline-mode) | |
211 (define-abbrev-table 'text-mode-abbrev-table ()) | |
212 (setq local-abbrev-table text-mode-abbrev-table) | |
213 (set-syntax-table text-mode-syntax-table) | |
214 (make-local-variable 'paragraph-start) | |
10888
388da827814c
(outline-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9478
diff
changeset
|
215 (setq paragraph-start (concat paragraph-start "\\|\\(" |
234 | 216 outline-regexp "\\)")) |
217 ;; Inhibit auto-filling of header lines. | |
218 (make-local-variable 'auto-fill-inhibit-regexp) | |
219 (setq auto-fill-inhibit-regexp outline-regexp) | |
220 (make-local-variable 'paragraph-separate) | |
10888
388da827814c
(outline-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9478
diff
changeset
|
221 (setq paragraph-separate (concat paragraph-separate "\\|\\(" |
234 | 222 outline-regexp "\\)")) |
9478
a8077b802b9e
* outline.el: (outline-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9378
diff
changeset
|
223 (make-local-variable 'font-lock-defaults) |
a8077b802b9e
* outline.el: (outline-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9378
diff
changeset
|
224 (setq font-lock-defaults '(outline-font-lock-keywords t)) |
7919
5823cf320f61
(outline-mode): Make change-major-mode-hook buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
7467
diff
changeset
|
225 (make-local-variable 'change-major-mode-hook) |
5876
82e1a78ab625
(outline-mode): Fix spelling of add-hook.
Karl Heuer <kwzh@gnu.org>
parents:
5855
diff
changeset
|
226 (add-hook 'change-major-mode-hook 'show-all) |
234 | 227 (run-hooks 'text-mode-hook 'outline-mode-hook)) |
228 | |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
229 (defcustom outline-minor-mode-prefix "\C-c@" |
8688
1aba2fd3fd13
(outline-minor-mode-prefix): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8643
diff
changeset
|
230 "*Prefix key to use for Outline commands in Outline minor mode. |
1aba2fd3fd13
(outline-minor-mode-prefix): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8643
diff
changeset
|
231 The value of this variable is checked as part of loading Outline mode. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
232 After that, changing the prefix key requires manipulating keymaps." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
233 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16147
diff
changeset
|
234 :group 'outlines) |
4622
a55b9c08e4af
(outline-minor-mode-prefix): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4187
diff
changeset
|
235 |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
236 (defvar outline-minor-mode-map nil) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
237 (if outline-minor-mode-map |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
238 nil |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
239 (setq outline-minor-mode-map (make-sparse-keymap)) |
3987
4eada6c0b8d4
(outline-mode-map): Add menu bar items.
Richard M. Stallman <rms@gnu.org>
parents:
3531
diff
changeset
|
240 (define-key outline-minor-mode-map [menu-bar] |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
241 outline-mode-menu-bar-map) |
4622
a55b9c08e4af
(outline-minor-mode-prefix): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4187
diff
changeset
|
242 (define-key outline-minor-mode-map outline-minor-mode-prefix |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
243 outline-mode-prefix-map)) |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
244 |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
245 (or (assq 'outline-minor-mode minor-mode-map-alist) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
246 (setq minor-mode-map-alist |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
247 (cons (cons 'outline-minor-mode outline-minor-mode-map) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
248 minor-mode-map-alist))) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
249 |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
250 (defun outline-minor-mode (&optional arg) |
2934
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
251 "Toggle Outline minor mode. |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
252 With arg, turn Outline minor mode on if arg is positive, off otherwise. |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
253 See the command `outline-mode' for more information on this mode." |
234 | 254 (interactive "P") |
255 (setq outline-minor-mode | |
256 (if (null arg) (not outline-minor-mode) | |
257 (> (prefix-numeric-value arg) 0))) | |
258 (if outline-minor-mode | |
259 (progn | |
260 (setq selective-display t) | |
261 (run-hooks 'outline-minor-mode-hook)) | |
4763
a57b0b715c04
(outline-minor-mode): Force update of modeline when outline-minor-mode
Brian Fox <bfox@gnu.org>
parents:
4623
diff
changeset
|
262 (setq selective-display nil)) |
5306
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
263 ;; When turning off outline mode, get rid of any ^M's. |
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
264 (or outline-minor-mode |
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
265 (outline-flag-region (point-min) (point-max) ?\n)) |
11575
090333911dc8
(outline-minor-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11455
diff
changeset
|
266 (force-mode-line-update)) |
234 | 267 |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
268 (defvar outline-level 'outline-level |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
269 "Function of no args to compute a header's nesting level in an outline. |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
270 It can assume point is at the beginning of a header line.") |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
271 |
6299
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
272 ;; This used to count columns rather than characters, but that made ^L |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
273 ;; appear to be at level 2 instead of 1. Columns would be better for |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
274 ;; tab handling, but the default regexp doesn't use tabs, and anyone |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
275 ;; who changes the regexp can also redefine the outline-level variable |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
276 ;; as appropriate. |
234 | 277 (defun outline-level () |
278 "Return the depth to which a statement is nested in the outline. | |
279 Point must be at the beginning of a header line. This is actually | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
280 the number of characters that `outline-regexp' matches." |
234 | 281 (save-excursion |
282 (looking-at outline-regexp) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
283 (- (match-end 0) (match-beginning 0)))) |
234 | 284 |
285 (defun outline-next-preface () | |
8153
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
286 "Skip forward to just before the next heading line. |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
287 If there's no following heading line, stop before the newline |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
288 at the end of the buffer." |
234 | 289 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") |
290 nil 'move) | |
8153
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
291 (goto-char (match-beginning 0))) |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
292 (if (memq (preceding-char) '(?\n ?\^M)) |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
293 (forward-char -1))) |
234 | 294 |
295 (defun outline-next-heading () | |
296 "Move to the next (possibly invisible) heading line." | |
297 (interactive) | |
298 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") | |
299 nil 'move) | |
300 (goto-char (1+ (match-beginning 0))))) | |
301 | |
302 (defun outline-back-to-heading () | |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
303 "Move to previous heading line, or beg of this line if it's a heading. |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
304 Only visible heading lines are considered." |
234 | 305 (beginning-of-line) |
306 (or (outline-on-heading-p) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
307 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
308 (error "before first heading"))) |
234 | 309 |
310 (defun outline-on-heading-p () | |
7269 | 311 "Return t if point is on a (visible) heading line." |
234 | 312 (save-excursion |
313 (beginning-of-line) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
314 (and (bolp) |
234 | 315 (looking-at outline-regexp)))) |
316 | |
317 (defun outline-end-of-heading () | |
318 (if (re-search-forward outline-heading-end-regexp nil 'move) | |
319 (forward-char -1))) | |
320 | |
321 (defun outline-next-visible-heading (arg) | |
322 "Move to the next visible heading line. | |
323 With argument, repeats or can move backward if negative. | |
324 A heading line is one that starts with a `*' (or that | |
325 `outline-regexp' matches)." | |
326 (interactive "p") | |
327 (if (< arg 0) | |
328 (beginning-of-line) | |
329 (end-of-line)) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
330 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
331 (error "")) |
234 | 332 (beginning-of-line)) |
333 | |
334 (defun outline-previous-visible-heading (arg) | |
335 "Move to the previous heading line. | |
336 With argument, repeats or can move forward if negative. | |
337 A heading line is one that starts with a `*' (or that | |
338 `outline-regexp' matches)." | |
339 (interactive "p") | |
340 (outline-next-visible-heading (- arg))) | |
341 | |
342 (defun outline-flag-region (from to flag) | |
343 "Hides or shows lines from FROM to TO, according to FLAG. | |
344 If FLAG is `\\n' (newline character) then text is shown, | |
345 while if FLAG is `\\^M' (control-M) the text is hidden." | |
3376
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
346 (let (buffer-read-only) |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
347 (subst-char-in-region from to |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
348 (if (= flag ?\n) ?\^M ?\n) |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
349 flag t))) |
234 | 350 |
351 (defun hide-entry () | |
352 "Hide the body directly following this heading." | |
353 (interactive) | |
354 (outline-back-to-heading) | |
355 (outline-end-of-heading) | |
356 (save-excursion | |
357 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\^M))) | |
358 | |
359 (defun show-entry () | |
360 "Show the body directly following this heading." | |
361 (interactive) | |
362 (save-excursion | |
363 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\n))) | |
364 | |
365 (defun hide-body () | |
366 "Hide all of buffer except headings." | |
367 (interactive) | |
368 (hide-region-body (point-min) (point-max))) | |
369 | |
370 (defun hide-region-body (start end) | |
371 "Hide all body lines in the region, but not headings." | |
372 (save-excursion | |
373 (save-restriction | |
374 (narrow-to-region start end) | |
375 (goto-char (point-min)) | |
376 (if (outline-on-heading-p) | |
377 (outline-end-of-heading)) | |
378 (while (not (eobp)) | |
379 (outline-flag-region (point) | |
380 (progn (outline-next-preface) (point)) ?\^M) | |
381 (if (not (eobp)) | |
382 (progn | |
383 (forward-char | |
384 (if (looking-at "[\n\^M][\n\^M]") | |
385 2 1)) | |
386 (outline-end-of-heading))))))) | |
387 | |
388 (defun show-all () | |
389 "Show all of the text in the buffer." | |
390 (interactive) | |
391 (outline-flag-region (point-min) (point-max) ?\n)) | |
392 | |
393 (defun hide-subtree () | |
394 "Hide everything after this heading at deeper levels." | |
395 (interactive) | |
396 (outline-flag-subtree ?\^M)) | |
397 | |
398 (defun hide-leaves () | |
399 "Hide all body after this heading at deeper levels." | |
400 (interactive) | |
401 (outline-back-to-heading) | |
402 (outline-end-of-heading) | |
403 (hide-region-body (point) (progn (outline-end-of-subtree) (point)))) | |
404 | |
405 (defun show-subtree () | |
406 "Show everything after this heading at deeper levels." | |
407 (interactive) | |
408 (outline-flag-subtree ?\n)) | |
409 | |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
410 (defun hide-sublevels (levels) |
7269 | 411 "Hide everything but the top LEVELS levels of headers, in whole buffer." |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
412 (interactive "p") |
6080
2f02deab5b9e
(hide-sublevels): Doc fix. Rename arg.
Richard M. Stallman <rms@gnu.org>
parents:
6077
diff
changeset
|
413 (if (< levels 1) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
414 (error "Must keep at least one level of headers")) |
6080
2f02deab5b9e
(hide-sublevels): Doc fix. Rename arg.
Richard M. Stallman <rms@gnu.org>
parents:
6077
diff
changeset
|
415 (setq levels (1- levels)) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
416 (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
417 (goto-char (point-min)) |
7312
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
418 ;; Keep advancing to the next top-level heading. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
419 (while (or (and (bobp) (outline-on-heading-p)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
420 (outline-next-heading)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
421 (let ((end (save-excursion (outline-end-of-subtree) (point)))) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
422 ;; Hide everything under that. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
423 (outline-flag-region (point) end ?\^M) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
424 ;; Show the first LEVELS levels under that. |
7316
00e2b88a5a8b
(hide-sublevels): Typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
7312
diff
changeset
|
425 (if (> levels 0) |
7312
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
426 (show-children levels)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
427 ;; Move to the next, since we already found it. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
428 (goto-char end))))) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
429 |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
430 (defun hide-other () |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
431 "Hide everything except for the current body and the parent headings." |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
432 (interactive) |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
433 (hide-sublevels 1) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
434 (let ((last (point)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
435 (pos (point))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
436 (while (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
437 (and (re-search-backward "[\n\r]" nil t) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
438 (eq (following-char) ?\r))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
439 (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
440 (beginning-of-line) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
441 (if (eq last (point)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
442 (progn |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
443 (outline-next-heading) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
444 (outline-flag-region last (point) ?\n)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
445 (show-children) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
446 (setq last (point))))))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
447 |
234 | 448 (defun outline-flag-subtree (flag) |
449 (save-excursion | |
450 (outline-back-to-heading) | |
451 (outline-end-of-heading) | |
452 (outline-flag-region (point) | |
453 (progn (outline-end-of-subtree) (point)) | |
454 flag))) | |
455 | |
456 (defun outline-end-of-subtree () | |
457 (outline-back-to-heading) | |
458 (let ((opoint (point)) | |
459 (first t) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
460 (level (funcall outline-level))) |
234 | 461 (while (and (not (eobp)) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
462 (or first (> (funcall outline-level) level))) |
234 | 463 (setq first nil) |
464 (outline-next-heading)) | |
6953
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
465 (if (memq (preceding-char) '(?\n ?\^M)) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
466 (progn |
6965 | 467 ;; Go to end of line before heading |
6953
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
468 (forward-char -1) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
469 (if (memq (preceding-char) '(?\n ?\^M)) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
470 ;; leave blank line before heading |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
471 (forward-char -1)))))) |
234 | 472 |
473 (defun show-branches () | |
474 "Show all subheadings of this heading, but not their bodies." | |
475 (interactive) | |
476 (show-children 1000)) | |
477 | |
478 (defun show-children (&optional level) | |
479 "Show all direct subheadings of this heading. | |
480 Prefix arg LEVEL is how many levels below the current level should be shown. | |
481 Default is enough to cause the following heading to appear." | |
482 (interactive "P") | |
483 (setq level | |
484 (if level (prefix-numeric-value level) | |
485 (save-excursion | |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
486 (outline-back-to-heading) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
487 (let ((start-level (funcall outline-level))) |
234 | 488 (outline-next-heading) |
5711
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
489 (if (eobp) |
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
490 1 |
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
491 (max 1 (- (funcall outline-level) start-level))))))) |
234 | 492 (save-excursion |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
493 (save-restriction |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
494 (outline-back-to-heading) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
495 (setq level (+ level (funcall outline-level))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
496 (narrow-to-region (point) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
497 (progn (outline-end-of-subtree) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
498 (if (eobp) (point-max) (1+ (point))))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
499 (goto-char (point-min)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
500 (while (and (not (eobp)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
501 (progn |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
502 (outline-next-heading) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
503 (not (eobp)))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
504 (if (<= (funcall outline-level) level) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
505 (save-excursion |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
506 (outline-flag-region (save-excursion |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
507 (forward-char -1) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
508 (if (memq (preceding-char) '(?\n ?\^M)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
509 (forward-char -1)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
510 (point)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
511 (progn (outline-end-of-heading) (point)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
512 ?\n))))))) |
234 | 513 |
514 (defun outline-up-heading (arg) | |
515 "Move to the heading line of which the present line is a subheading. | |
516 With argument, move up ARG levels." | |
517 (interactive "p") | |
518 (outline-back-to-heading) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
519 (if (eq (funcall outline-level) 1) |
234 | 520 (error "")) |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
521 (while (and (> (funcall outline-level) 1) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
522 (> arg 0) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
523 (not (bobp))) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
524 (let ((present-level (funcall outline-level))) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
525 (while (not (< (funcall outline-level) present-level)) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
526 (outline-previous-visible-heading 1)) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
527 (setq arg (- arg 1))))) |
234 | 528 |
529 (defun outline-forward-same-level (arg) | |
7269 | 530 "Move forward to the ARG'th subheading at same level as this one. |
531 Stop at the first and last subheadings of a superior heading." | |
234 | 532 (interactive "p") |
533 (outline-back-to-heading) | |
534 (while (> arg 0) | |
535 (let ((point-to-move-to (save-excursion | |
536 (outline-get-next-sibling)))) | |
537 (if point-to-move-to | |
538 (progn | |
539 (goto-char point-to-move-to) | |
540 (setq arg (1- arg))) | |
541 (progn | |
542 (setq arg 0) | |
543 (error "")))))) | |
544 | |
545 (defun outline-get-next-sibling () | |
7269 | 546 "Move to next heading of the same level, and return point or nil if none." |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
547 (let ((level (funcall outline-level))) |
234 | 548 (outline-next-visible-heading 1) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
549 (while (and (> (funcall outline-level) level) |
234 | 550 (not (eobp))) |
551 (outline-next-visible-heading 1)) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
552 (if (< (funcall outline-level) level) |
234 | 553 nil |
554 (point)))) | |
555 | |
556 (defun outline-backward-same-level (arg) | |
7269 | 557 "Move backward to the ARG'th subheading at same level as this one. |
558 Stop at the first and last subheadings of a superior heading." | |
234 | 559 (interactive "p") |
560 (outline-back-to-heading) | |
561 (while (> arg 0) | |
562 (let ((point-to-move-to (save-excursion | |
563 (outline-get-last-sibling)))) | |
564 (if point-to-move-to | |
565 (progn | |
566 (goto-char point-to-move-to) | |
567 (setq arg (1- arg))) | |
568 (progn | |
569 (setq arg 0) | |
570 (error "")))))) | |
571 | |
572 (defun outline-get-last-sibling () | |
7269 | 573 "Move to next heading of the same level, and return point or nil if none." |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
574 (let ((level (funcall outline-level))) |
234 | 575 (outline-previous-visible-heading 1) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
576 (while (and (> (funcall outline-level) level) |
234 | 577 (not (bobp))) |
578 (outline-previous-visible-heading 1)) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
579 (if (< (funcall outline-level) level) |
234 | 580 nil |
581 (point)))) | |
582 | |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
583 (provide 'outline) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
584 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
585 ;;; outline.el ends here |