aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-05 21:59:09 +0000
committerRichard M. Stallman1997-04-05 21:59:09 +0000
commit78897d3d9f61ae24e85035761d71ea252b8fd59b (patch)
treea9c31918cc0136411418d99926b111d874daaa04 /lisp
parente694581dc0592c4dccd9c3b4aaf11b1fed50a264 (diff)
downloademacs-78897d3d9f61ae24e85035761d71ea252b8fd59b.tar.gz
emacs-78897d3d9f61ae24e85035761d71ea252b8fd59b.zip
(texinfo-make-menu): Accept args BEGINNING and END.
(texinfo-update-node): Accept args BEGINNING and END. (texinfo-all-menus-update): Pass region explicitly. (texinfo-master-menu, texinfo-every-node-update): Likewise.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/textmodes/texnfo-upd.el110
1 files changed, 43 insertions, 67 deletions
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el
index f55374f5cb4..724d3617d13 100644
--- a/lisp/textmodes/texnfo-upd.el
+++ b/lisp/textmodes/texnfo-upd.el
@@ -36,16 +36,16 @@
36;; * insert or update the menu for a section, 36;; * insert or update the menu for a section,
37;; * create a master menu for a Texinfo source file. 37;; * create a master menu for a Texinfo source file.
38;; 38;;
39;; Passed an argument, the `texinfo-update-node' and 39;; With a prefix argument, the `texinfo-update-node' and
40;; `texinfo-make-menu' functions do their jobs in the region. 40;; `texinfo-make-menu' functions do their jobs in the region.
41;; 41;;
42;; In brief, the functions for creating or updating nodes and menus, are: 42;; In brief, the functions for creating or updating nodes and menus, are:
43;; 43;;
44;; texinfo-update-node (&optional region-p) 44;; texinfo-update-node (&optional beginning end)
45;; texinfo-every-node-update () 45;; texinfo-every-node-update ()
46;; texinfo-sequential-node-update (&optional region-p) 46;; texinfo-sequential-node-update (&optional region-p)
47;; 47;;
48;; texinfo-make-menu (&optional region-p) 48;; texinfo-make-menu (&optional beginning end)
49;; texinfo-all-menus-update () 49;; texinfo-all-menus-update ()
50;; texinfo-master-menu () 50;; texinfo-master-menu ()
51;; 51;;
@@ -80,11 +80,11 @@
80 80
81;;; The update node functions described in detail 81;;; The update node functions described in detail
82 82
83;; The `texinfo-update-node' function without an argument inserts 83;; The `texinfo-update-node' command with no prefix argument inserts
84;; the correct next, previous and up pointers for the node in which 84;; the correct next, previous and up pointers for the node in which
85;; point is located (i.e., for the node preceding point). 85;; point is located (i.e., for the node preceding point).
86 86
87;; With an argument, the `texinfo-update-node' function inserts the 87;; With prefix argument, the `texinfo-update-node' function inserts the
88;; correct next, previous and up pointers for the nodes inside the 88;; correct next, previous and up pointers for the nodes inside the
89;; region. 89;; region.
90 90
@@ -149,13 +149,11 @@
149 149
150;;; Code: 150;;; Code:
151 151
152;;; The menu making functions 152(defun texinfo-make-menu (&optional beginning end)
153
154(defun texinfo-make-menu (&optional region-p)
155 "Without any prefix argument, make or update a menu. 153 "Without any prefix argument, make or update a menu.
156Make the menu for the section enclosing the node found following point. 154Make the menu for the section enclosing the node found following point.
157 155
158Non-nil argument (prefix, if interactive) means make or update menus 156A prefix argument means make or update menus
159for nodes within or part of the marked region. 157for nodes within or part of the marked region.
160 158
161Whenever a menu exists, and is being updated, the descriptions that 159Whenever a menu exists, and is being updated, the descriptions that
@@ -163,25 +161,24 @@ are associated with node names in the pre-existing menu are
163incorporated into the new menu. Otherwise, the nodes' section titles 161incorporated into the new menu. Otherwise, the nodes' section titles
164are inserted as descriptions." 162are inserted as descriptions."
165 163
166 (interactive "P") 164 (interactive
167 (if (not region-p) 165 (if prefix-arg
166 (list (point) (mark))))
167 (if (null beginning)
168 (let ((level (texinfo-hierarchic-level))) 168 (let ((level (texinfo-hierarchic-level)))
169 (texinfo-make-one-menu level) 169 (texinfo-make-one-menu level)
170 (message "Done...updated the menu. You may save the buffer.")) 170 (message "Menu updated"))
171 ;; else 171 ;; else
172 (message "Making or updating menus in %s... " (buffer-name)) 172 (message "Making or updating menus in %s... " (buffer-name))
173 (let ((beginning (region-beginning)) 173 (save-excursion
174 (region-end (region-end)) 174 (goto-char (min beginning end))
175 (level (progn ; find section type following point 175 ;; find section type following point
176 (goto-char (region-beginning)) 176 (let ((level (texinfo-hierarchic-level))
177 (texinfo-hierarchic-level)))) 177 (region-end (max beginning end)))
178 (if (= region-end beginning)
179 (error "Please mark a region!"))
180 (save-excursion
181 (save-restriction 178 (save-restriction
182 (widen) 179 (widen)
183 180
184 (while (texinfo-find-lower-level-node level region-end) 181 (while (texinfo-find-lower-level-node level region-end)
185 (setq level (texinfo-hierarchic-level)) ; new, lower level 182 (setq level (texinfo-hierarchic-level)) ; new, lower level
186 (texinfo-make-one-menu level)) 183 (texinfo-make-one-menu level))
187 184
@@ -191,7 +188,7 @@ are inserted as descriptions."
191 (while (texinfo-find-lower-level-node level region-end) 188 (while (texinfo-find-lower-level-node level region-end)
192 (setq level (texinfo-hierarchic-level)) ; new, lower level 189 (setq level (texinfo-hierarchic-level)) ; new, lower level
193 (texinfo-make-one-menu level)))))) 190 (texinfo-make-one-menu level))))))
194 (message "Done...updated menus. You may save the buffer."))) 191 (message "Making or updating menus in %s...done" (buffer-name))))
195 192
196(defun texinfo-make-one-menu (level) 193(defun texinfo-make-one-menu (level)
197 "Make a menu of all the appropriate nodes in this section. 194 "Make a menu of all the appropriate nodes in this section.
@@ -248,21 +245,11 @@ nodes in the buffer before updating the menus."
248 (progn 245 (progn
249 (message "Updating all nodes in %s ... " (buffer-name)) 246 (message "Updating all nodes in %s ... " (buffer-name))
250 (sleep-for 2) 247 (sleep-for 2)
251 (push-mark (point-max) t) 248 (texinfo-update-node (point-min) (point-max))))
252 (goto-char (point-min))
253 ;; Using the mark to pass bounds this way
254 ;; is kludgy, but it's not worth fixing. -- rms.
255 (let ((mark-active t))
256 (texinfo-update-node t))))
257 249
258 (message "Updating all menus in %s ... " (buffer-name)) 250 (message "Updating all menus in %s ... " (buffer-name))
259 (sleep-for 2) 251 (sleep-for 2)
260 (push-mark (point-max) t) 252 (texinfo-make-menu (point-max) (point-min))
261 (goto-char (point-min))
262 ;; Using the mark to pass bounds this way
263 ;; is kludgy, but it's not worth fixing. -- rms.
264 (let ((mark-active t))
265 (texinfo-make-menu t))
266 253
267 (if master-menu-p 254 (if master-menu-p
268 (progn 255 (progn
@@ -799,15 +786,11 @@ title of the section containing the menu."
799 (message "Making a master menu in %s ...first updating all nodes... " 786 (message "Making a master menu in %s ...first updating all nodes... "
800 (buffer-name)) 787 (buffer-name))
801 (sleep-for 2) 788 (sleep-for 2)
802 (push-mark (point-max) t) 789 (texinfo-update-node (point-min) (point-max))
803 (goto-char (point-min))
804 (texinfo-update-node t)
805 790
806 (message "Updating all menus in %s ... " (buffer-name)) 791 (message "Updating all menus in %s ... " (buffer-name))
807 (sleep-for 2) 792 (sleep-for 2)
808 (push-mark (point-max) t) 793 (texinfo-make-menu (point-min) (point-max))))
809 (goto-char (point-min))
810 (texinfo-make-menu t)))
811 794
812 (message "Now making the master menu in %s... " (buffer-name)) 795 (message "Now making the master menu in %s... " (buffer-name))
813 (sleep-for 2) 796 (sleep-for 2)
@@ -1227,15 +1210,14 @@ document; the values are regular expressions.")
1227;;; Updating a node 1210;;; Updating a node
1228 1211
1229;;;###autoload 1212;;;###autoload
1230(defun texinfo-update-node (&optional region-p) 1213(defun texinfo-update-node (&optional beginning end)
1231 "Without any prefix argument, update the node in which point is located. 1214 "Without any prefix argument, update the node in which point is located.
1232Non-nil argument (prefix, if interactive) means update the nodes in the 1215Interactively, a prefix argument means to operate on the region.
1233marked region.
1234 1216
1235The functions for creating or updating nodes and menus, and their 1217The functions for creating or updating nodes and menus, and their
1236keybindings, are: 1218keybindings, are:
1237 1219
1238 texinfo-update-node (&optional region-p) \\[texinfo-update-node] 1220 texinfo-update-node (&optional beginning end) \\[texinfo-update-node]
1239 texinfo-every-node-update () \\[texinfo-every-node-update] 1221 texinfo-every-node-update () \\[texinfo-every-node-update]
1240 texinfo-sequential-node-update (&optional region-p) 1222 texinfo-sequential-node-update (&optional region-p)
1241 1223
@@ -1248,41 +1230,35 @@ keybindings, are:
1248The `texinfo-column-for-description' variable specifies the column to 1230The `texinfo-column-for-description' variable specifies the column to
1249which menu descriptions are indented. Its default value is 32." 1231which menu descriptions are indented. Its default value is 32."
1250 1232
1251 (interactive "P") 1233 (interactive
1252 (if (not region-p) 1234 (if prefix-arg
1253 ;; update a single node 1235 (list (point) (mark))))
1236 (if (null beginning)
1237 ;; Update a single node.
1254 (let ((auto-fill-function nil) (auto-fill-hook nil)) 1238 (let ((auto-fill-function nil) (auto-fill-hook nil))
1255 (if (not (re-search-backward "^@node" (point-min) t)) 1239 (if (not (re-search-backward "^@node" (point-min) t))
1256 (error "Node line not found before this position.")) 1240 (error "Node line not found before this position"))
1257 (texinfo-update-the-node) 1241 (texinfo-update-the-node)
1258 (message "Done...updated the node. You may save the buffer.")) 1242 (message "Done...updated the node. You may save the buffer."))
1259 ;; else 1243 ;; else
1260 (let ((auto-fill-function nil) 1244 (let ((auto-fill-function nil)
1261 (auto-fill-hook nil) 1245 (auto-fill-hook nil))
1262 (beginning (region-beginning)) 1246 (save-excursion
1263 (end (region-end))) 1247 (save-restriction
1264 (if (= end beginning) 1248 (narrow-to-region beginning end)
1265 (error "Please mark a region!")) 1249 (goto-char (point-min))
1266 (save-restriction 1250 (while (re-search-forward "^@node" (point-max) t)
1267 (narrow-to-region beginning end) 1251 (beginning-of-line)
1268 (goto-char beginning) 1252 (texinfo-update-the-node))
1269 (push-mark (point) t) 1253 (goto-char (point-max))
1270 (while (re-search-forward "^@node" (point-max) t) 1254 (message "Done...nodes updated in region. You may save the buffer."))))))
1271 (beginning-of-line)
1272 (texinfo-update-the-node))
1273 (message "Done...updated nodes in region. You may save the buffer.")))))
1274 1255
1275;;;###autoload 1256;;;###autoload
1276(defun texinfo-every-node-update () 1257(defun texinfo-every-node-update ()
1277 "Update every node in a Texinfo file." 1258 "Update every node in a Texinfo file."
1278 (interactive) 1259 (interactive)
1279 (save-excursion 1260 (save-excursion
1280 (push-mark (point-max) t) 1261 (texinfo-update-node (point-min) (point-max))
1281 (goto-char (point-min))
1282 ;; Using the mark to pass bounds this way
1283 ;; is kludgy, but it's not worth fixing. -- rms.
1284 (let ((mark-active t))
1285 (texinfo-update-node t))
1286 (message "Done...updated every node. You may save the buffer."))) 1262 (message "Done...updated every node. You may save the buffer.")))
1287 1263
1288(defun texinfo-update-the-node () 1264(defun texinfo-update-the-node ()