;ELC ;;; compiled by cthomp@willow on Thu Aug 12 00:37:06 1993 ;;; from file /era/era-0.80/editor/lisp/modes/hideif.el ;;; emacs version 19.8 (beta8) Lucid. ;;; bytecomp version 2.15; 14-jul-93. ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "This file was compiled for Emacs 19.")) (defvar hide-ifdef-mode-map nil "\ Keymap used with hide-ifdef mode") (defconst hide-ifdef-mode-prefix-key "" "\ Prefix key for all hide-ifdef-mode commands.") (defvar hide-ifdef-mode-map-before nil "\ Buffer-local variable to store a copy of the local keymap before hide-ifdef-mode modifies it.") (fset 'define-hide-ifdef-mode-map #[nil " #################M" [hide-ifdef-mode-map make-sparse-keymap define-key "d" hide-ifdef-define "u" hide-ifdef-undef "D" hide-ifdef-set-define-alist "U" hide-ifdef-use-define-alist "h" hide-ifdefs "s" show-ifdefs "" hide-ifdef-block "" show-ifdef-block "" forward-ifdef "" backward-ifdef "" down-ifdef "" up-ifdef "" next-ifdef "" previous-ifdef "" hide-ifdef-toggle-read-only where-is-internal toggle-read-only nil t hide-ifdef-toggle-outside-read-only] 6]) (fset 'hif-update-mode-line #[nil " !" [set-buffer-modified-p buffer-modified-p] 2 "\ Update mode-line by setting buffer-modified to itself."]) (defvar hide-ifdef-mode nil "\ non-nil when hide-ifdef-mode is activated.") (defvar hide-ifdef-hiding nil "\ non-nil when text may be hidden.") (byte-code " B B" [hide-ifdef-hiding minor-mode-alist (hide-ifdef-hiding " Hiding") hide-ifdef-mode (hide-ifdef-mode " Ifdef")] 2) (fset 'hide-ifdef-mode #[(arg) "!\n ?\n!V \"\"\"!! !!!!  !!!\" ! ! !!" [make-local-variable hide-ifdef-mode arg prefix-numeric-value 0 hif-update-mode-line modify-syntax-entry 95 "w" 38 "." 124 hide-ifdef-env default-value hide-ifdef-hiding hif-outside-read-only buffer-read-only hide-ifdef-mode-map-before current-local-map use-local-map copy-keymap local-unset-key hide-ifdef-mode-prefix-key local-set-key hide-ifdef-mode-map define-hide-ifdef-mode-map run-hooks hide-ifdef-mode-hook hide-ifdef-initially hide-ifdefs show-ifdefs message "Enter hide-ifdef-mode." "Exit hide-ifdef-mode."] 3 "\ Toggle hide-ifdef-mode. Thus this is a minor mode, albeit a large one. With arg, turn hide-ifdef-mode on iff arg is positive. In hide-ifdef-mode, code within #ifdef constructs that the C preprocessor would eliminate may be hidden from view. Several variables affect how the hiding is done: hide-ifdef-env An association list of defined and undefined symbols for the current buffer. Initially, the global value of hide-ifdef-env is used. hide-ifdef-define-alist An association list of defined symbol lists. Use hide-ifdef-set-define-alist to save the current hide-ifdef-env and hide-ifdef-use-define-alist to set the current hide-ifdef-env from one of the lists in hide-ifdef-define-alist. hide-ifdef-lines Set to non-nil to not show #if, #ifdef, #ifndef, #else, and #endif lines when hiding. hide-ifdef-initially Indicates whether hide-ifdefs should be called when hide-ifdef-mode is activated. hide-ifdef-read-only Set to non-nil if you want to make buffers read only while hiding. After show-ifdefs, read-only status is restored to previous value. \\{hide-ifdef-mode-map}" "P"]) (fset 'hif-outline-flag-region #[(from to flag) " Ž UȪ%*" [buffer-modified-p modp ((set-buffer-modified-p modp)) subst-char-in-region from to flag 10 13 t] 6 "\ Hides or shows lines from FROM to TO, according to FLAG. If FLAG is \\n (newline character) then text is shown, while if FLAG is \\^M (control-M) the text is hidden."]) (fset 'hif-show-all #[nil "ed#" [hif-outline-flag-region 10] 4 "\ Show all of the text in the current buffer." nil]) (fset 'hide-ifdef-region #[(start end) " \n#" [hif-outline-flag-region start end 13] 4 "\ START is the start of a #if or #else form. END is the ending part. Everything including these lines is made invisible."]) (fset 'hif-show-ifdef-region #[(start end) " \n#" [hif-outline-flag-region start end 10] 4 "\ Everything between START and END is made visible."]) (defvar hide-ifdef-evaluator 'eval "\ The evaluator is given a canonical form and returns T if text under that form should be displayed.") (defvar hif-undefined-symbol nil "\ ...is by default considered to be false.") (defvar hide-ifdef-env nil "\ An alist of defined symbols and their values.") (fset 'hif-set-var #[(var value) " B\nB" [var value hide-ifdef-env] 2 "\ Prepend (var value) pair to hide-ifdef-env."]) (byte-code "MMP P P P    " [hif-lookup #[(var) " \n\" A )" [assoc var hide-ifdef-env val hif-undefined-symbol] 4] hif-defined #[(var) " !" [hif-lookup var] 2] "\\(^\\| \\)[ ]*#[ ]*" hif-cpp-prefix "ifndef" hif-ifndef-regexp "if\\(n?def\\)?[ ]+" hif-ifx-regexp "else" hif-else-regexp "endif" hif-endif-regexp "\\|" hif-ifx-else-endif-regexp] 5) (fset 'hif-infix-to-prefix #[(token-list) "GU@DD!" [token-list 1 hif-lookup quote hif-parse-if-exp] 3 "\ Convert list of tokens in infix into prefix list"]) (byte-code "ć" ["^\\(!\\|&&\\|||\\|[()]\\|\\w+\\)" hif-token-regexp "\\*/" hif-end-of-comment nil] 1) (fset 'hif-tokenize #[(expr-string) "\nG W\n #\n SIh\n #\n SI\n\n #\n #\n SI? \n #\n O \n SI ΘϪ ИѪ ҘӪ Ԙժ ֘ת ؘ٪ ! B)\n\" +" [nil 0 expr-string expr-length expr-start token-list string-match "^[ ]+" 10 "^/\\*" hif-end-of-comment "$" hif-token-regexp token "||" or "&&" and "!" not "defined" hif-defined "(" lparen ")" rparen intern error "Bad #if expression: %s"] 4 "\ Separate string into a list of tokens"]) (fset 'hif-parse-if-exp #[(token-list) " \n\n\"" [hif-nexttoken hif-expr token error "Error: unexpected token: %s"] 4 "\ Parse the TOKEN-LIST. Return translated list in prefix form."]) (fset 'hif-nexttoken #[nil "@A " [token-list token] 1 "\ Pop the next token from token-list into the let variable \"token\"."]) (fset 'hif-expr #[nil " \n= Ep )" [hif-term result token or hif-nexttoken] 3 "\ Parse and expression of the form expr : term | expr '||' term."]) (fset 'hif-term #[nil " \n= Ep )" [hif-factor result token and hif-nexttoken] 3 "\ Parse a term of the form term : factor | term '&&' factor."]) (fset 'hif-factor #[nil "= D= =\" )= =!  >\" =!  )DD >!  )DD" [token not hif-nexttoken hif-factor lparen hif-expr result rparen error "Bad token in parenthesized expression: %s" hif-defined "Error: expected \"(\" after \"defined\"" ident (or and not hif-defined lparen rparen) "Error: unexpected token: %s" "Error: expected \")\" after identifier" quote (or and) "Error: missing identifier" hif-lookup] 4 "\ Parse a factor of the form factor : '!' factor | '(' expr ')' | 'defined(' id ')' | id."]) (fset 'hif-canonicalize #[nil " ! !`w`{!!\n\n\nD\n," [looking-at hif-ifndef-regexp negate re-search-forward hif-ifx-regexp "^\n " nil expr-string hif-infix-to-prefix hif-tokenize expr not] 3 "\ When at beginning of #ifX, returns a canonical (evaluatable) form for the expression."]) (fset 'hif-find-any-ifX #[nil " d#y" [re-search-forward hif-ifx-regexp t 0] 4 "\ Position at beginning of next #if, #ifdef, or #ifndef, including one on this line."]) (fset 'hif-find-next-relevant #[nil "\nd#y" [nil re-search-forward hif-ifx-else-endif-regexp t 0] 4 "\ Position at beginning of next #ifdef, #ifndef, #else, #endif, NOT including one on this line."]) (fset 'hif-find-previous-relevant #[nil "y\ne#yć" [0 re-search-backward hif-ifx-else-endif-regexp t nil] 4 "\ Position at beginning of previous #ifdef, #ifndef, #else, #endif, NOT including one on this line."]) (byte-code "MMM" [hif-looking-at-ifX #[nil " !" [looking-at hif-ifx-regexp] 2] hif-looking-at-endif #[nil " !" [looking-at hif-endif-regexp] 2] hif-looking-at-else #[nil " !" [looking-at hif-else-regexp] 2]] 2) (fset 'hif-ifdef-to-endif #[nil " Ň!" [hif-find-next-relevant hif-looking-at-ifX hif-ifdef-to-endif hif-looking-at-else hif-looking-at-endif done error "Missmatched #ifdef #endif pair"] 2 "\ If positioned at #ifX or #else form, skip to corresponding #endif."]) (fset 'hif-endif-to-ifdef #[nil "` `U!) ȇɇ" [start hif-find-previous-relevant error "Missmatched #ifdef #endif pair" hif-looking-at-endif hif-endif-to-ifdef hif-looking-at-else hif-looking-at-ifX done t] 2 "\ If positioned at #endif form, skip backward to corresponding #ifX."]) (fset 'forward-ifdef #[(&optional arg) "W[!W[` b!)\\" [arg 1 0 backward-ifdef start hif-looking-at-ifX hif-find-next-relevant hif-ifdef-to-endif error "No following #ifdef"] 2 "\ Move point to beginning of line of the next ifdef-endif. With argument, do this that many times." "p"]) (fset 'backward-ifdef #[(&optional arg) "W[!WSy` b!)Y" [arg 1 0 forward-ifdef start hif-looking-at-endif hif-find-previous-relevant hif-endif-to-ifdef error "No previous #ifdef"] 2 "\ Move point to beginning of the previous ifdef-endif. With argument, do this that many times." "p"]) (fset 'down-ifdef #[nil "` ?b!)" [start hif-find-next-relevant hif-looking-at-ifX hif-looking-at-else error "No following #ifdef"] 2 "\ Move point to beginning of nested ifdef or else-part." nil]) (fset 'up-ifdef #[nil "y` `U!)" [0 start hif-looking-at-endif hif-find-previous-relevant hif-endif-to-ifdef error "No previous #ifdef"] 2 "\ Move point to beginning of enclosing ifdef or else-part." nil]) (fset 'next-ifdef #[(&optional arg) "W[!WS lry!i" [arg 1 0 previous-ifdef hif-find-next-relevant error "No following #ifdefs, #elses, or #endifs"] 2 "\ Move to the beginning of the next #ifX, #else, or #endif. With argument, do this that many times." "p"]) (fset 'previous-ifdef #[(&optional arg) "W[!WS` `U!)g" [arg 1 0 next-ifdef start hif-find-previous-relevant error "No previous #ifdefs, #elses, or #endifs"] 2 "\ Move to the beginning of the previous #ifX, #else, or #endif. With argument, do this that many times." "p"]) (byte-code "MMMMM" [hif-make-range #[(else-p start end &optional else) " \n F" [else-p start else end] 4] hif-range-else-p #[(range) "" [range 0] 2] hif-range-start #[(range) "" [range 1] 2] hif-range-else #[(range) "" [range 2] 2] hif-range-end #[(range) "" [range 3] 2]] 2) (fset 'hif-find-range #[nil "y` t `` t !` \n $-" [0 nil end else else-p start hif-find-next-relevant hif-looking-at-ifX hif-ifdef-to-endif hif-looking-at-else t error "Found two elses in a row? Broken!" hif-make-range] 5 "\ Returns a Range structure describing the current #if region. Point is left unchanged."]) (fset 'hif-hide-line #[(point) " b Ďy`U?`S`\"+" [hide-ifdef-lines point buffer-modified-p modp ((set-buffer-modified-p modp)) 0 1 hide-ifdef-region] 3 "\ Hide the line containing point. Does nothing if hide-ifdef-lines is nil."]) (fset 'hif-recurse-on #[(start end) "b`\n} *" [start nil end hide-ifdef-guts] 2 "\ Call hide-ifdef-guts after narrowing to end of START line and END line."]) (fset 'hif-possibly-hide #[nil " \n!! !\n!\n!!\n!\n!S\"\n!\n!\"\n!\n!\"\n!\n!!\n!\n!S\"\n!\n!\"`\n!S\"\n!!\n!b*" [hif-canonicalize hif-find-range range test hif-hide-line hif-range-end hide-ifdef-evaluator hif-range-else-p hif-range-else hide-ifdef-region hif-recurse-on hif-range-start nil] 4 "\ Called at #ifX expression, this hides those parts that should be hidden, according to judgement of hide-ifdef-evaluator."]) (fset 'hide-ifdef-guts #[nil "eb w)" [hif-find-any-ifX hif-possibly-hide] 1 "\ Does the work of hide-ifdefs, except for the work that's pointless to redo on a recursive entry."]) (defvar hide-ifdef-initially nil "\ *Non-nil if hide-ifdefs should be called when hide-ifdef-mode is first activated.") (defvar hide-ifdef-hiding nil "\ Non-nil if text might be hidden.") (defvar hide-ifdef-read-only nil "\ *Set to non-nil if you want buffer to be read-only while hiding text.") (defvar hif-outside-read-only nil "\ Internal variable. Saves the value of buffer-read-only while hiding.") (defvar hide-ifdef-lines nil "\ *Set to t if you don't want to see the #ifX, #else, and #endif lines.") (fset 'hide-ifdef-toggle-read-only #[nil "?ê\"  " [hide-ifdef-read-only message "Hide-Read-Only %s" "ON" "OFF" hide-ifdef-hiding hif-outside-read-only buffer-read-only hif-update-mode-line] 3 "\ Toggle hide-ifdef-read-only." nil]) (fset 'hide-ifdef-toggle-outside-read-only #[nil "?ê\"  " [hif-outside-read-only message "Read only %s" "ON" "OFF" hide-ifdef-hiding hide-ifdef-read-only buffer-read-only hif-update-mode-line] 3 "\ Replacement for toggle-read-only within hide-ifdef-mode." nil]) (fset 'hide-ifdef-define #[(var) " \" " [hif-set-var var t hide-ifdef-hiding hide-ifdefs] 3 "\ Define a VAR so that #ifdef VAR would be included." "SDefine what? "]) (fset 'hide-ifdef-undef #[(var) " \" " [hif-set-var var nil hide-ifdef-hiding hide-ifdefs] 3 "\ Undefine a VAR so that #ifdef VAR would not be included." "SUndefine what? "]) (fset 'hide-ifdefs #[nil "!\n!      !" [message "Hiding..." hide-ifdef-mode 1 hide-ifdef-hiding show-ifdefs buffer-read-only toggle-read-only t selective-display hide-ifdef-guts hide-ifdef-read-only hif-outside-read-only "Hiding done"] 2 "\ Hide the contents of some #ifdefs. Assume that defined symbols have been added to hide-ifdef-env. The text hidden is the text that would not be included by the C preprocessor if it were given the file with those symbols defined. Turn off hiding by calling show-ifdef." nil]) (fset 'show-ifdefs #[nil "  ‰" [buffer-read-only toggle-read-only nil selective-display hif-show-all hif-outside-read-only hide-ifdef-hiding] 2 "\ Cancel the effects of hide-ifdef. The contents of all #ifdefs is shown." nil]) (fset 'hif-find-ifdef-block #[nil "y ` `S)y t `S^\n*" [nil max-bottom 0 hif-looking-at-else hif-looking-at-ifX up-ifdef top hif-ifdef-to-endif hif-looking-at-endif hif-find-next-relevant bottom] 2 "\ Utilitiy for hide and show ifdef-block. Set top and bottom of ifdef block."]) (fset 'hide-ifdef-block #[nil "!\n Ɖ \" !T! * " [hide-ifdef-mode 1 buffer-read-only toggle-read-only t selective-display nil bottom top hif-find-ifdef-block hide-ifdef-region hide-ifdef-lines hif-hide-line hide-ifdef-hiding hide-ifdef-read-only hif-outside-read-only] 3 "\ Hide the ifdef block (true or false part) enclosing or before the cursor." nil]) (fset 'show-ifdef-block #[nil " y`S`\")Ɖ S\"* )" [buffer-read-only old-read-only toggle-read-only hide-ifdef-lines 0 hif-show-ifdef-region nil bottom top hif-find-ifdef-block] 4 "\ Show the ifdef block (true or false part) enclosing or before the cursor." nil]) (defvar hide-ifdef-define-alist nil "\ A global assoc list of pre-defined symbol lists") (fset 'hif-compress-define-list #[(env) "\n\" @ @ B Aq *" [mapcar #[(arg) " @! @" [hif-lookup arg] 2] env nil new-defs defs] 4 "\ Compress the define list ENV into a list of defined symbols only."]) (fset 'hide-ifdef-set-define-alist #[(name) "\n!B B" [name hif-compress-define-list hide-ifdef-env hide-ifdef-define-alist] 3 "\ Set the association for NAME to hide-ifdef-env." "SSet define list: "]) (fset 'hide-ifdef-use-define-alist #[(name) " \n\" A\" \" )" [assoc name hide-ifdef-define-alist define-list mapcar #[(arg) "B" [arg t] 2] hide-ifdef-env error "No define list for %s" hide-ifdef-hiding hide-ifdefs] 4 "\ Set hide-ifdef-env to the define list specified by NAME." "SUse define list: "])