aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-12-25 20:44:18 +0000
committerRichard M. Stallman1995-12-25 20:44:18 +0000
commitf5356416e92bd9bfbd66387e5782e01338d153ea (patch)
treeed8e585fb6feb6d96cbd835b41eb03f7d52825c3
parent4464514e6e41f905c4f2e51797603d7f111d0c08 (diff)
downloademacs-f5356416e92bd9bfbd66387e5782e01338d153ea.tar.gz
emacs-f5356416e92bd9bfbd66387e5782e01338d153ea.zip
Many doc fixes.
(hide-ifdefs): New arg NOMSG. (hif-before-revert-function): New function. Put on after-revert-hook.
-rw-r--r--lisp/progmodes/hideif.el68
1 files changed, 36 insertions, 32 deletions
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index b6d7ee6f3be..6b1d56b94b8 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -239,19 +239,19 @@ hide-ifdef-read-only
239 (if hide-ifdef-initially 239 (if hide-ifdef-initially
240 (hide-ifdefs) 240 (hide-ifdefs)
241 (show-ifdefs)) 241 (show-ifdefs))
242 (message "Enter hide-ifdef-mode.") 242 (message "Enter Hide-Ifdef mode")
243 ) 243 )
244 ; else end hide-ifdef-mode 244 ; else end hide-ifdef-mode
245 (if hide-ifdef-hiding 245 (if hide-ifdef-hiding
246 (show-ifdefs)) 246 (show-ifdefs))
247 (message "Exit hide-ifdef-mode.") 247 (message "Exit Hide-Ifdef mode")
248 )) 248 ))
249 249
250 250
251;; from outline.el with docstring fixed. 251;; from outline.el with docstring fixed.
252(defun hif-outline-flag-region (from to flag) 252(defun hif-outline-flag-region (from to flag)
253 "Hides or shows lines from FROM to TO, according to FLAG. If FLAG 253 "Hides or shows lines from FROM to TO, according to FLAG.
254is \\n (newline character) then text is shown, while if FLAG is \\^M 254If FLAG is \\n (newline character) then text is shown, while if FLAG is \\^M
255\(control-M) the text is hidden." 255\(control-M) the text is hidden."
256 (let ((modp (buffer-modified-p))) 256 (let ((modp (buffer-modified-p)))
257 (unwind-protect (progn 257 (unwind-protect (progn
@@ -266,6 +266,14 @@ is \\n (newline character) then text is shown, while if FLAG is \\^M
266 (interactive) 266 (interactive)
267 (hif-outline-flag-region (point-min) (point-max) ?\n)) 267 (hif-outline-flag-region (point-min) (point-max) ?\n))
268 268
269;; By putting this on after-revert-hook, we arrange that it only
270;; does anything when revert-buffer avoids turning off the mode.
271;; (That can happen in VC.)
272(defun hif-before-revert-function ()
273 (and hide-ifdef-mode hide-ifdef-hiding
274 (hide-ifdefs t)))
275(add-hook 'after-revert-hook 'hif-before-revert-function)
276
269(defun hide-ifdef-region (start end) 277(defun hide-ifdef-region (start end)
270 "START is the start of a #if or #else form. END is the ending part. 278 "START is the start of a #if or #else form. END is the ending part.
271Everything including these lines is made invisible." 279Everything including these lines is made invisible."
@@ -281,8 +289,11 @@ Everything including these lines is made invisible."
281 289
282;===%%SF%% evaluation (Start) === 290;===%%SF%% evaluation (Start) ===
283 291
292;; It is not useful to set this to anything but `eval'.
293;; In fact, the variable might as well be eliminated.
284(defvar hide-ifdef-evaluator 'eval 294(defvar hide-ifdef-evaluator 'eval
285 "The evaluator is given a canonical form and returns T if text under 295 "The function to use to evaluate a form.
296The evaluator is given a canonical form and returns t if text under
286that form should be displayed.") 297that form should be displayed.")
287 298
288(defvar hif-undefined-symbol nil 299(defvar hif-undefined-symbol nil
@@ -419,7 +430,7 @@ that form should be displayed.")
419 token) 430 token)
420 431
421(defun hif-expr () 432(defun hif-expr ()
422 "Parse and expression of the form 433 "Parse an expression as found in #if.
423 expr : term | expr '||' term." 434 expr : term | expr '||' term."
424 (let ((result (hif-term))) 435 (let ((result (hif-term)))
425 (while (eq token 'or) 436 (while (eq token 'or)
@@ -428,8 +439,7 @@ that form should be displayed.")
428 result)) 439 result))
429 440
430(defun hif-term () 441(defun hif-term ()
431 "Parse a term of the form 442 "Parse a term : eq-expr | term '&&' eq-expr."
432 term : eq-expr | term '&&' eq-expr."
433 (let ((result (hif-eq-expr))) 443 (let ((result (hif-eq-expr)))
434 (while (eq token 'and) 444 (while (eq token 'and)
435 (hif-nexttoken) 445 (hif-nexttoken)
@@ -437,8 +447,7 @@ that form should be displayed.")
437 result)) 447 result))
438 448
439(defun hif-eq-expr () 449(defun hif-eq-expr ()
440 "Parse a term of the form 450 "Parse an eq-expr : math | eq-expr '=='|'!=' math."
441 eq-expr : math | eq-expr '=='|'!=' math."
442 (let ((result (hif-math)) 451 (let ((result (hif-math))
443 (eq-token nil)) 452 (eq-token nil))
444 (while (or (eq token 'equal) (eq token 'hif-notequal)) 453 (while (or (eq token 'equal) (eq token 'hif-notequal))
@@ -448,7 +457,7 @@ that form should be displayed.")
448 result)) 457 result))
449 458
450(defun hif-math () 459(defun hif-math ()
451 "Parse an expression of the form 460 "Parse an expression with + or - and simpler things.
452 math : factor | math '+|-' factor." 461 math : factor | math '+|-' factor."
453 (let ((result (hif-factor)) 462 (let ((result (hif-factor))
454 (math-op nil)) 463 (math-op nil))
@@ -459,8 +468,7 @@ that form should be displayed.")
459 result)) 468 result))
460 469
461(defun hif-factor () 470(defun hif-factor ()
462 "Parse a factor of the form 471 "Parse a factor: '!' factor | '(' expr ')' | 'defined(' id ')' | id."
463 factor : '!' factor | '(' expr ')' | 'defined(' id ')' | id."
464 (cond 472 (cond
465 ((eq token 'not) 473 ((eq token 'not)
466 (hif-nexttoken) 474 (hif-nexttoken)
@@ -520,8 +528,7 @@ that form should be displayed.")
520 528
521 529
522(defun hif-canonicalize () 530(defun hif-canonicalize ()
523 "When at beginning of #ifX, returns a canonical (evaluatable) 531 "When at beginning of #ifX, returns a Lisp expression for its condition."
524 form for the expression."
525 (save-excursion 532 (save-excursion
526 (let ((negate (looking-at hif-ifndef-regexp))) 533 (let ((negate (looking-at hif-ifndef-regexp)))
527 (re-search-forward hif-ifx-regexp) 534 (re-search-forward hif-ifx-regexp)
@@ -536,8 +543,7 @@ that form should be displayed.")
536 543
537 544
538(defun hif-find-any-ifX () 545(defun hif-find-any-ifX ()
539 "Position at beginning of next #if, #ifdef, or #ifndef, including one on 546 "Move to next #if..., or #ifndef, at point or after."
540this line."
541; (message "find ifX at %d" (point)) 547; (message "find ifX at %d" (point))
542 (prog1 548 (prog1
543 (re-search-forward hif-ifx-regexp (point-max) t) 549 (re-search-forward hif-ifx-regexp (point-max) t)
@@ -545,8 +551,7 @@ this line."
545 551
546 552
547(defun hif-find-next-relevant () 553(defun hif-find-next-relevant ()
548 "Position at beginning of next #ifdef, #ifndef, #else, #endif, 554 "Move to next #if..., #else, or #endif, after the current line."
549NOT including one on this line."
550; (message "hif-find-next-relevant at %d" (point)) 555; (message "hif-find-next-relevant at %d" (point))
551 (end-of-line) 556 (end-of-line)
552 ; avoid infinite recursion by only going to beginning of line if match found 557 ; avoid infinite recursion by only going to beginning of line if match found
@@ -554,8 +559,7 @@ NOT including one on this line."
554 (beginning-of-line))) 559 (beginning-of-line)))
555 560
556(defun hif-find-previous-relevant () 561(defun hif-find-previous-relevant ()
557 "Position at beginning of previous #ifdef, #ifndef, #else, #endif, 562 "Move to previous #if..., #else, or #endif, before the current line."
558NOT including one on this line."
559; (message "hif-find-previous-relevant at %d" (point)) 563; (message "hif-find-previous-relevant at %d" (point))
560 (beginning-of-line) 564 (beginning-of-line)
561 ; avoid infinite recursion by only going to beginning of line if match found 565 ; avoid infinite recursion by only going to beginning of line if match found
@@ -815,8 +819,8 @@ Point is left unchanged."
815 (hide-ifdef-guts)))) 819 (hide-ifdef-guts))))
816 820
817(defun hif-possibly-hide () 821(defun hif-possibly-hide ()
818 "Called at #ifX expression, this hides those parts that should be 822 "Called at #ifX expression, this hides those parts that should be hidden.
819hidden, according to judgement of `hide-ifdef-evaluator'." 823It uses the judgement of `hide-ifdef-evaluator'."
820; (message "hif-possibly-hide") (sit-for 1) 824; (message "hif-possibly-hide") (sit-for 1)
821 (let ((test (hif-canonicalize)) 825 (let ((test (hif-canonicalize))
822 (range (hif-find-range))) 826 (range (hif-find-range)))
@@ -851,8 +855,8 @@ hidden, according to judgement of `hide-ifdef-evaluator'."
851 855
852 856
853(defun hide-ifdef-guts () 857(defun hide-ifdef-guts ()
854 "Does the work of `hide-ifdefs', except for the work that's pointless 858 "Does most of the work of `hide-ifdefs'.
855to redo on a recursive entry." 859It does not do the work that's pointless to redo on a recursive entry."
856; (message "hide-ifdef-guts") 860; (message "hide-ifdef-guts")
857 (save-excursion 861 (save-excursion
858 (goto-char (point-min)) 862 (goto-char (point-min))
@@ -866,8 +870,7 @@ to redo on a recursive entry."
866 870
867;;;###autoload 871;;;###autoload
868(defvar hide-ifdef-initially nil 872(defvar hide-ifdef-initially nil
869 "*Non-nil if `hide-ifdefs' should be called when Hide-Ifdef mode 873 "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated.")
870is first activated.")
871 874
872;;;###autoload 875;;;###autoload
873(defvar hide-ifdef-read-only nil 876(defvar hide-ifdef-read-only nil
@@ -878,7 +881,7 @@ is first activated.")
878 881
879;;;###autoload 882;;;###autoload
880(defvar hide-ifdef-lines nil 883(defvar hide-ifdef-lines nil
881 "*Set to t if you don't want to see the #ifX, #else, and #endif lines.") 884 "*Non-nil means hide the #ifX, #else, and #endif lines.")
882 885
883(defun hide-ifdef-toggle-read-only () 886(defun hide-ifdef-toggle-read-only ()
884 "Toggle hide-ifdef-read-only." 887 "Toggle hide-ifdef-read-only."
@@ -891,7 +894,7 @@ is first activated.")
891 (force-mode-line-update)) 894 (force-mode-line-update))
892 895
893(defun hide-ifdef-toggle-outside-read-only () 896(defun hide-ifdef-toggle-outside-read-only ()
894 "Replacement for `toggle-read-only' within Hide Ifdef mode." 897 "Replacement for `toggle-read-only' within Hide-Ifdef mode."
895 (interactive) 898 (interactive)
896 (setq hif-outside-read-only (not hif-outside-read-only)) 899 (setq hif-outside-read-only (not hif-outside-read-only))
897 (message "Read only %s" 900 (message "Read only %s"
@@ -916,7 +919,7 @@ is first activated.")
916 (if hide-ifdef-hiding (hide-ifdefs))) 919 (if hide-ifdef-hiding (hide-ifdefs)))
917 920
918 921
919(defun hide-ifdefs () 922(defun hide-ifdefs (&optional nomsg)
920 "Hide the contents of some #ifdefs. 923 "Hide the contents of some #ifdefs.
921Assume that defined symbols have been added to `hide-ifdef-env'. 924Assume that defined symbols have been added to `hide-ifdef-env'.
922The text hidden is the text that would not be included by the C 925The text hidden is the text that would not be included by the C
@@ -935,11 +938,12 @@ Turn off hiding by calling `show-ifdefs'."
935 (setq hide-ifdef-hiding t) 938 (setq hide-ifdef-hiding t)
936 (hide-ifdef-guts)) 939 (hide-ifdef-guts))
937 (setq buffer-read-only (or hide-ifdef-read-only hif-outside-read-only)) 940 (setq buffer-read-only (or hide-ifdef-read-only hif-outside-read-only))
938 (message "Hiding done")) 941 (or nomsg
942 (message "Hiding done")))
939 943
940 944
941(defun show-ifdefs () 945(defun show-ifdefs ()
942 "Cancel the effects of `hide-ifdef'. The contents of all #ifdefs is shown." 946 "Cancel the effects of `hide-ifdef': show the contents of all #ifdefs."
943 (interactive) 947 (interactive)
944 (setq buffer-read-only hif-outside-read-only) 948 (setq buffer-read-only hif-outside-read-only)
945 (setq selective-display nil) ; defaults 949 (setq selective-display nil) ; defaults