annotate lisp/hyperbole/kotl/kvspec.el @ 100:4be1180a9e89 r20-1b2

Import from CVS: tag r20-1b2
author cvs
date Mon, 13 Aug 2007 09:15:11 +0200
parents 131b0175ea99
children 8619ce7e4c50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: kvspec.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Koutline view specification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: outlines, wp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; ORIG-DATE: 21-Oct-95 at 15:17:07
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
11 ;; LAST-MOD: 4-Dec-96 at 15:36:12 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; Copyright (C) 1995, Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; Developed with support from Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Koutliner view specs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; + means support code has been written already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; + all: Show all lines of cells and all cells in the outline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; + blank: Blank lines are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; b - on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; + cutoff: Show only NUM lines per cell, 0 = all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; c - set default cutoff lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; cNUM - set cutoff lines to NUM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; descend: Only entries below this entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; + elide: Ellipses are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; e - ellipses on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; filter: Regexp or filter program to select entries for view,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; off=select non-matching entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; glue: Freeze any group of entries selected to stay at top of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; window, off=freeze those not-in-group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; include: Include an entry referenced by a link.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; + level: Some levels are hidden.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; l - set default level clipping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; lNUM - set level clipping to NUM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; name: Display leading names within cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; m - show names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; + number: Cell numbers are on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; n - set default labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; n0 - display idstamp labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; n1 - display alpha labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; n2 - display partial alpha labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; n. - display legal labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; n* - display star labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; n~ - turn off labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; rest: Only following cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; synthesize: Use a named generator function to generate entries for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; view.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; view: Turn koutliner view mode on. Standard insertion keys then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; can be used for browsing and view setting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (require 'kview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar kvspec:current nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "String that represents the current view spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 It is local to each koutline. Nil value means it has not been set yet.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun kvspec:activate (&optional view-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "Activate optional VIEW-SPEC or existing view spec in the current koutline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 VIEW-SPEC is a string or t, which means recompute the current view spec. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 <${hyperb:dir}/kotl/EXAMPLE.kotl, 2b17=048> for details on valid view specs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (interactive (list (read-string "Set view spec: " kvspec:current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (kotl-mode:is-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (or (equal view-spec "") (equal view-spec kvspec:current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (setq view-spec nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (kvspec:initialize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (kvspec:update view-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (kvspec:update-view))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun kvspec:initialize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "Ensure that view spec settings will be local to the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (if (and (fboundp 'local-variable-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (local-variable-p 'kvspec:current (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (make-local-variable 'kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (make-local-variable 'kvspec:string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defun kvspec:levels-to-show (levels-to-keep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 "Hide all cells in outline at levels deeper than LEVELS-TO-KEEP (a number).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Shows any hidden cells within LEVELS-TO-KEEP. 1 is the first level. 0 means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 display all levels of cells."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if (null levels-to-keep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq levels-to-keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (read-from-minibuffer "Show cells down to level (0 = show all levels): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 nil nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (setq levels-to-keep (prefix-numeric-value levels-to-keep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (< levels-to-keep 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (error "(kvspec:levels-to-show): Must display at least one level."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (kview:map-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (function (lambda (kview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (if (/= (kcell-view:level) levels-to-keep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (kotl-mode:show-tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (kotl-mode:hide-subtree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; Move to last cell in hidden subtree, to skip further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; processing of these cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (kcell-view:next t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (kcell-view:previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (goto-char (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 kview t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (kview:set-attr kview 'levels-to-show levels-to-keep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun kvspec:show-lines-per-cell (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "Show NUM lines per cell."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (and (integerp num) (>= num 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 nil
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
125 (error "(kvspec:show-lines-per-cell): Invalid lines per cell, '%d'" num))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (kview:set-attr kview 'lines-to-show num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let (start end count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if (zerop num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; Show all lines in cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (kview:map-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (lambda (kview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; Use free variable label-sep-len bound in kview:map-tree for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq start (goto-char (kcell-view:start nil label-sep-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 end (kcell-view:end-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; Show all lines in cell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (subst-char-in-region start end ?\r ?\n t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 kview t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; Show NUM lines in cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (kview:map-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (lambda (kview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; Use free variable label-sep-len bound in kview:map-tree for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq start (goto-char (kcell-view:start nil label-sep-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 end (kcell-view:end-contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 count (1- num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; Hide all lines in cell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (subst-char-in-region start end ?\n ?\r t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; Expand num - 1 newlines to show num lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (while (and (> count 0) (search-forward "\r" end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (replace-match "\n") (setq count (1- count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 kview t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun kvspec:toggle-blank-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "Toggle blank lines between cells on or off."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq kvspec:current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (if (string-match "b" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (hypb:replace-match-string "b" kvspec:current "" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (concat "b" kvspec:current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (kvspec:blank-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (kvspec:update-modeline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defun kvspec:update (view-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 "Update current view spec according to VIEW-SPEC but don't change the view.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 VIEW-SPEC is a string or t, which means recompute the current view spec. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 <${hyperb:dir}/kotl/EXAMPLE.kotl, 2b17=048> for details on valid view specs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (cond ((stringp view-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; Use given view-spec after removing extraneous characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq kvspec:current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (hypb:replace-match-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "[^.*~0-9abcdefgilnrsv]+" view-spec "" t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ((or (eq view-spec t) (null kvspec:current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq kvspec:current (kvspec:compute))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; Update display using current specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (kvspec:update-modeline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun kvspec:blank-lines ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
184 "Turn blank lines on or off according to 'kvspec:current'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (let ((modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (string-match "b" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; On
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (progn (kview:set-attr kview 'blank-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (kproperty:remove (point-min) (point-max) '(invisible t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; Off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (kview:set-attr kview 'blank-lines nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (while (re-search-backward "[\n\r][\n\r]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; Make blank lines invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (kproperty:put (1+ (point)) (min (+ (point) 2) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 '(invisible t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (set-buffer-modified-p modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun kvspec:compute ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Compute and return current view spec string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; a - Show all cells and cell lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; Never compute this setting (use it only within links) since it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; expose all carefully hidden outline items if the user forgets to turn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; it off when he resets the view specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; b - blank separator lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (kview:get-attr kview 'blank-lines) "b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; c - cutoff lines per cell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((lines (kview:get-attr kview 'lines-to-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (if (zerop lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (concat "c" (int-to-string lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; e - ellipses on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if selective-display-ellipses "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; l - hide some levels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let ((levels (kview:get-attr kview 'levels-to-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (if (zerop levels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (concat "l" (int-to-string levels))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; n - numbering type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((type (kview:label-type kview)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (cond ((eq type 'no) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ((eq type kview:default-label-type) "n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (t (concat "n" (char-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (car (rassq (kview:label-type kview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 kvspec:label-type-alist)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun kvspec:elide ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
237 "Turn ellipses display following clipped cells on or off according to 'kvspec:current'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq selective-display-ellipses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (string-match "e" kvspec:current) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defun kvspec:hide-levels ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
242 "Show a set number of cell levels according to 'kvspec:current'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; "l" means use value of kview:default-levels-to-show.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; "l0" means show all levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (let (levels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if (not (string-match "l\\([0-9]+\\)?" kvspec:current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; Don't change the view if no view spec is given but note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; all levels should be shown in the future.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (kview:set-attr kview 'levels-to-show 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq levels (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (substring kvspec:current (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq levels kview:default-levels-to-show))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (kview:set-attr kview 'levels-to-show levels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (kvspec:levels-to-show levels))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun kvspec:lines-to-show ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
259 "Show a set number of lines per cell according to 'kvspec:current'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; "c" means use value of kview:default-lines-to-show.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; "c0" means show all lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (cond ((not (string-match "c\\([0-9]+\\)?" kvspec:current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; Don't change the view if no view spec is given but note that all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; lines should be shown in the future.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (kview:set-attr kview 'lines-to-show 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ((match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (kvspec:show-lines-per-cell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (string-to-int (substring kvspec:current (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (t (kvspec:show-lines-per-cell kview:default-lines-to-show))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun kvspec:numbering ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
273 "Set the type of numbering (label) display according to 'kvspec:current'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (not (string-match "n\\([.*~0-2]\\)?" kvspec:current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; "n" means use value of kview:default-label-type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; "n0" means display idstamps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; "n1" means display alpha labels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; "n2" means display partial alpha labels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; "n." means display legal labels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; "n*" means star labels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; "n~" means no labels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (let (spec type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq spec (string-to-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (substring kvspec:current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 type (cdr (assq spec kvspec:label-type-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq type kview:default-label-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (kview:set-label-type kview type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defun kvspec:update-modeline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "Setup or update display of the current kview spec in the modeline."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (stringp kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq kvspec:string (format kvspec:string-format kvspec:current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if (memq 'kvspec:string mode-line-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq mode-line-format (copy-sequence mode-line-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (let ((elt (or (memq 'mode-line-buffer-identification mode-line-format)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
300 (memq 'modeline-buffer-identification
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
301 mode-line-format))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
302 (if elt
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
303 (setcdr elt (cons 'kvspec:string (cdr elt)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
304 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
305 ;; XEmacs 19.14 introduced extents into the modeline that we
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
306 ;; must work around.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
307 (if (and hyperb:xemacs-p (string-lessp "19.14" hyperb:xemacs-p))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
308 (let ((mf modeline-format)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
309 elt)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
310 (while mf
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
311 (setq elt (car mf))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
312 (if (and (consp elt) (eq (cdr elt) 'modeline-buffer-identification))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
313 (progn (setcdr mf (cons 'kvspec:string (cdr mf)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
314 (setq mf nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
315 (setq mf (cdr mf)))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun kvspec:update-view ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
318 "Update view according to current setting of local 'kvspec:current' variable."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (let ((modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (if (string-match "a" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (kotl-mode:show-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (kvspec:blank-lines) ;; b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; This must come before kvspec:lines-to-show or else it could show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; lines that should be hidden.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (kvspec:hide-levels) ;; l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (kvspec:lines-to-show) ;; c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if (string-match "d" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (kvspec:elide) ;; e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (if (string-match "f" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (string-match "g" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (if (string-match "i" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (if (string-match "r" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (if (string-match "s" kvspec:current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; Do this last since it can trigger an error if partial alpha is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (kvspec:numbering) ;; n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-buffer-modified-p modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defvar kvspec:label-type-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 '((?0 . idstamp) (?1 . alpha) (?2 . partial-alpha)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (?. . legal) (?* . star) (?~ . no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "Alist of (view-spec-character . label-type) pairs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defvar kvspec:string ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "String displayed in koutline modelines to reflect the current view spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 It is local to each koutline. Set this to nil to disable modeline display of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 the view spec settings.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defvar kvspec:string-format " <|%s>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Format of the kview spec modeline display.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
377 It must contain a '%s' which is replaced with the current set of view spec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 characters at run-time.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (provide 'kvspec)