(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.")

(defun define-hide-ifdef-mode-map nil (byte-code "p #################M" [hide-ifdef-mode-map nil t 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 hide-ifdef-toggle-outside-read-only] 22))

(defun hif-update-mode-line nil "\
Update mode-line by setting buffer-modified to itself." (byte-code " !" [set-buffer-modified-p buffer-modified-p] 3))

(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.")

(or (assq (quote hide-ifdef-hiding) minor-mode-alist) (setq minor-mode-alist (cons (quote (hide-ifdef-hiding " Hiding")) minor-mode-alist)))

(or (assq (quote hide-ifdef-mode) minor-mode-alist) (setq minor-mode-alist (cons (quote (hide-ifdef-mode " Ifdef")) minor-mode-alist)))

(defun hide-ifdef-mode (arg) "\
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:

	An association list of defined and undefined symbols for the
	current buffer.  Initially, the global value of hide-ifdef-env is used.

	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.

	Set to non-nil to not show #if, #ifdef, #ifndef, #else, and
	#endif lines when hiding.

	Indicates whether hide-ifdefs should be called when hide-ifdef-mode
	is activated.

	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}" (interactive "P") (byte-code "Ɉ!	??	!V \"\"\"!!!!!
!  !!!\" !w y ! !!" [hide-ifdef-mode arg hide-ifdef-env hide-ifdef-hiding hif-outside-read-only buffer-read-only hide-ifdef-mode-map-before hide-ifdef-mode-prefix-key hide-ifdef-initially nil make-local-variable prefix-numeric-value 0 hif-update-mode-line modify-syntax-entry 95 "w" 38 "." 124 default-value ide-ifdef-mode-map-before current-local-map use-local-map copy-keymap local-unset-key local-set-key hide-ifdef-mode-map define-hide-ifdef-mode-map run-hooks hide-ifdef-mode-hook hide-ifdefs show-ifdefs message "Enter hide-ifdef-mode." "Exit hide-ifdef-mode."] 27))

(defun hif-outline-flag-region (from to flag) "\
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." (byte-code " Ǝ	
Uɂ%))" [modp from to flag t buffer-modified-p ((byte-code "!" [modp set-buffer-modified-p] 2)) subst-char-in-region 10 13] 7))

(defun hif-show-all nil "\
Show all of the text in the current buffer." (interactive) (byte-code "ed#" [nil hif-outline-flag-region 10] 4))

(defun hide-ifdef-region (start end) "\
START is the start of a #if or #else form.  END is the ending part.
Everything including these lines is made invisible." (byte-code "	#" [start end hif-outline-flag-region 13] 4))

(defun hif-show-ifdef-region (start end) "\
Everything between START and END is made visible." (byte-code "	#" [start end hif-outline-flag-region 10] 4))

(defvar hide-ifdef-evaluator (quote 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.")

(defun hif-set-var (var value) "\
Prepend (var value) pair to hide-ifdef-env." (byte-code "	
BB" [hide-ifdef-env var value] 2))

(defun hif-lookup (var) (byte-code "	
\"A)" [val var hide-ifdef-env hif-undefined-symbol assoc] 3))

(defun hif-defined (var) (byte-code "!" [var hif-lookup] 2))

(defconst hif-cpp-prefix "\\(^\\|
\\)[ 	]*#[ 	]*")

(defconst hif-ifndef-regexp (concat hif-cpp-prefix "ifndef"))

(defconst hif-ifx-regexp (concat hif-cpp-prefix "if\\(n?def\\)?[ 	]+"))

(defconst hif-else-regexp (concat hif-cpp-prefix "else"))

(defconst hif-endif-regexp (concat hif-cpp-prefix "endif"))

(defconst hif-ifx-else-endif-regexp (concat hif-ifx-regexp "\\|" hif-else-regexp "\\|" hif-endif-regexp))

(defun hif-infix-to-prefix (token-list) "\
Convert list of tokens in infix into prefix list" (byte-code "GU@DD!" [token-list 1 hif-lookup quote hif-parse-if-exp] 3))

(defconst hif-token-regexp "^\\(!\\|&&\\|||\\|[()]\\|\\w+\\)")

(defconst hif-end-of-comment "\\*/")

(defun hif-tokenize (expr-string) "\
Separate string into a list of tokens" (byte-code "G
SI\"|҂\"Ԃ\"ւ\"؂\"ڂ\"܂!B)\"!+" [token-list nil expr-start expr-length expr-string hif-end-of-comment hif-token-regexp token t 0 string-match "^[ 	]+" match-end 10 "^/\\*" "$" string-equal "||" or "&&" and "!" not "defined" hif-defined "(" lparen ")" rparen intern error "Bad #if expression: %s" nreverse] 21))

(defun hif-parse-if-exp (token-list) "\
Parse the TOKEN-LIST.  Return translated list in prefix form." (byte-code "  
\"" [token hif-nexttoken hif-expr error "Error: unexpected token: %s"] 6))

(defun hif-nexttoken nil "\
Pop the next token from token-list into the let variable \"token\"." (byte-code "	@	A" [token token-list] 2))

(defun hif-expr nil "\
Parse and expression of the form
       expr : term | expr '||' term." (byte-code " 	=  E)" [result token hif-term or hif-nexttoken] 7))

(defun hif-term nil "\
Parse a term of the form
       term : factor | term '&&' factor." (byte-code " 	=  E)" [result token hif-factor and hif-nexttoken] 7))

(defun hif-factor nil "\
Parse a factor of the form
       factor : '!' factor | '(' expr ')' | 'defined(' id ')' | id." (byte-code "=  D=2  =?*\". 	)=p =?E! >U\" =?c! 
DD)" [token result ident t not hif-nexttoken hif-factor lparen hif-expr rparen error "Bad token in parenthesized expression: %s" hif-defined "Error: expected \"(\" after \"define\"" (or and not hif-defined lparen rparen) "Error: unexpected token: %s" "Error: expected \")\" after identifier" quote (or and) "Error: missing identifier" hif-lookup] 18))

(defun hif-canonicalize nil "\
When at beginning of #ifX, returns a canonical (evaluatable)
       form for the expression." (byte-code "	!
!`!`\"!!\"D#*))" [negate hif-ifndef-regexp hif-ifx-regexp expr-string expr looking-at re-search-forward buffer-substring skip-chars-forward "^

" hif-infix-to-prefix hif-tokenize not] 8))

(defun hif-find-any-ifX nil "\
Position at beginning of next #if, #ifdef, or #ifndef, including one on
this line." (byte-code "d# " [hif-ifx-regexp t re-search-forward beginning-of-line] 4))

(defun hif-find-next-relevant nil "\
Position at beginning of next #ifdef, #ifndef, #else, #endif,
NOT including one on this line." (byte-code " d#
 " [hif-ifx-else-endif-regexp t end-of-line re-search-forward beginning-of-line] 5))

(defun hif-find-previous-relevant nil "\
Position at beginning of previous #ifdef, #ifndef, #else, #endif,
NOT including one on this line." (byte-code " e#
 " [hif-ifx-else-endif-regexp t beginning-of-line re-search-backward] 5))

(defun hif-looking-at-ifX nil (byte-code "!" [hif-ifx-regexp looking-at] 2))

(defun hif-looking-at-endif nil (byte-code "!" [hif-endif-regexp looking-at] 2))

(defun hif-looking-at-else nil (byte-code "!" [hif-else-regexp looking-at] 2))

(defun hif-ifdef-to-endif nil "\
If positioned at #ifX or #else form, skip to corresponding #endif." (byte-code "    &  & #Ƃ&!" [t 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"] 9))

(defun hif-endif-to-ifdef nil "\
If positioned at #endif form, skip backward to corresponding #ifX." (byte-code "` `U!)   1 ' 1 0ɂ1ʇ" [start t 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 nil] 9))

(defun forward-ifdef (&optional arg) "\
Move point to beginning of line of the next ifdef-endif.
       With argument, do this that many times." (interactive "p") (byte-code "ˆ	ÉW[!W@[` ?*  5 ;	b!)" [arg start nil 1 0 backward-ifdef hif-looking-at-ifX hif-find-next-relevant hif-ifdef-to-endif error "No following #ifdef"] 8))

(defun backward-ifdef (&optional arg) "\
Move point to beginning of the previous ifdef-endif.
       With argument, do this that many times." (interactive "p") (byte-code "ˆ	ÉW[!WCS ` ?-  8 >	b!)" [arg start nil 1 0 forward-ifdef beginning-of-line hif-looking-at-endif hif-find-previous-relevant hif-endif-to-ifdef error "No previous #ifdef"] 9))

(defun down-ifdef nil "\
Move point to beginning of nested ifdef or else-part." (interactive) (byte-code "`   b!)" [start nil hif-find-next-relevant hif-looking-at-ifX hif-looking-at-else error "No following #ifdef"] 5))

(defun up-ifdef nil "\
Move point to beginning of enclosing ifdef or else-part." (interactive) (byte-code " ` ?   `U!!)" [start nil beginning-of-line hif-looking-at-endif hif-find-previous-relevant hif-endif-to-ifdef error "No previous #ifdef"] 7))

(defun next-ifdef (&optional arg) "\
Move to the beginning of the next #ifX, #else, or #endif.
       With argument, do this that many times." (interactive "p") (byte-code "	‰W[!W1S l- !" [arg nil 1 0 previous-ifdef hif-find-next-relevant beginning-of-line error "No following #ifdefs, #elses, or #endifs"] 6))

(defun previous-ifdef (&optional arg) "\
Move to the beginning of the previous #ifX, #else, or #endif.
       With argument, do this that many times." (interactive "p") (byte-code "ˆ	ÉW[!W3S` 	`U.!)" [arg start nil 1 0 next-ifdef hif-find-previous-relevant error "No previous #ifdefs, #elses, or #endifs"] 5))

(defun hif-make-range (else-p start end &optional else) (byte-code "	
F" [else-p start else end] 4))

(defun hif-range-else-p (range) (byte-code "\"" [range elt 0] 3))

(defun hif-range-start (range) (byte-code "\"" [range elt 1] 3))

(defun hif-range-else (range) (byte-code "\"" [range elt 2] 3))

(defun hif-range-end (range) (byte-code "\"" [range elt 3] 3))

(defun hif-find-range nil "\
Returns a Range structure describing the current #if region.
Point is left unchanged." (byte-code " `     -ʼn`0`	S  F  8 O!`	$,)" [start else-p nil else end t beginning-of-line hif-find-next-relevant hif-looking-at-ifX hif-ifdef-to-endif hif-looking-at-else error "Found two elses in a row?  Broken!" hif-make-range] 17))

(defun hif-hide-line (point) "\
Hide the line containing point.  Does nothing if
hide-ifdef-lines is nil." (byte-code "	b Ď `U?`S`\")))" [hide-ifdef-lines point modp buffer-modified-p ((byte-code "!" [modp set-buffer-modified-p] 2)) beginning-of-line 1 hide-ifdef-region] 5))

(defun hif-recurse-on (start end) "\
Call hide-ifdef-guts after narrowing to end of START line and END
line." (byte-code "b `	\" ))" [start end end-of-line narrow-to-region hide-ifdef-guts] 4))

(defun hif-possibly-hide nil "\
Called at #ifX expression, this hides those parts that should be
hidden, according to judgement of hide-ifdef-evaluator." (byte-code "  	!!
\"?	!4	!!	!	!S\"	!	!\"<	!	!\"g	!`	!!	!	!S\"	!	!\"g`	!S\"	!!	!b *" [test range hide-ifdef-evaluator t hif-canonicalize hif-find-range hif-hide-line hif-range-end funcall hif-range-else-p hif-range-else hide-ifdef-region hif-recurse-on hif-range-start end-of-line] 33))

(defun hide-ifdef-guts nil "\
Does the work of hide-ifdefs, except for the work that's pointless
to redo on a recursive entry." (byte-code "eb  )" [hif-find-any-ifX hif-possibly-hide] 4))

(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.")

(defun hide-ifdef-toggle-read-only nil "\
Toggle hide-ifdef-read-only." (interactive) (byte-code "Ĉ?ǂ\"	 " [hide-ifdef-read-only hide-ifdef-hiding buffer-read-only hif-outside-read-only nil message "Hide-Read-Only %s" "ON" "OFF" hif-update-mode-line] 3))

(defun hide-ifdef-toggle-outside-read-only nil "\
Replacement for toggle-read-only within hide-ifdef-mode." (interactive) (byte-code "Ĉ?ǂ\"
 " [hif-outside-read-only buffer-read-only hide-ifdef-hiding hide-ifdef-read-only nil message "Read only %s" "ON" "OFF" hif-update-mode-line] 3))

(defun hide-ifdef-define (var) "\
Define a VAR so that #ifdef VAR would be included." (interactive "SDefine what? ") (byte-code "È\"

 " [var t hide-ifdef-hiding nil hif-set-var hide-ifdefs] 3))

(defun hide-ifdef-undef (var) "\
Undefine a VAR so that #ifdef VAR would not be included." (interactive "SUndefine what? ") (byte-code "\"

 " [var nil hide-ifdef-hiding hif-set-var hide-ifdefs] 3))

(defun hide-ifdefs nil "\
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." (interactive) (byte-code "Lj!?!	 
.3 !" [hide-ifdef-mode hide-ifdef-hiding buffer-read-only selective-display t hide-ifdef-read-only hif-outside-read-only nil message "Hiding..." 1 show-ifdefs toggle-read-only hide-ifdef-guts "Hiding done"] 8))

(defun show-ifdefs nil "\
Cancel the effects of hide-ifdef.  The contents of all #ifdefs is shown." (interactive) (byte-code "ˆ ‰  ‰" [buffer-read-only selective-display nil hif-outside-read-only hide-ifdef-hiding toggle-read-only hif-show-all] 5))

(defun hif-find-ifdef-block nil "\
Utilitiy for hide and show ifdef-block.  Set top and bottom of ifdef block." (byte-code "  
 ? ` `S)  ?-  <  .`S^))" [max-bottom top bottom nil beginning-of-line hif-looking-at-else hif-looking-at-ifX up-ifdef hif-ifdef-to-endif hif-looking-at-endif hif-find-next-relevant] 13))

(defun hide-ifdef-block nil "\
Hide the ifdef block (true or false part) enclosing or before the cursor." (interactive) (byte-code "ʈ?
!	 É 
\"/!
T!É*=	B " [hide-ifdef-mode buffer-read-only selective-display t top bottom hide-ifdef-lines hide-ifdef-hiding hide-ifdef-read-only hif-outside-read-only nil 1 toggle-read-only hif-find-ifdef-block hide-ifdef-region hif-hide-line] 8))

(defun show-ifdef-block nil "\
Show the ifdef block (true or false part) enclosing or before the cursor." (interactive) (byte-code "ň	
 `S `\"), S\"*3 )" [old-read-only buffer-read-only hide-ifdef-lines top bottom nil toggle-read-only beginning-of-line hif-show-ifdef-region end-of-line hif-find-ifdef-block] 8))

(defvar hide-ifdef-define-alist nil "\
A global assoc list of pre-defined symbol lists")

(defun hif-compress-define-list (env) "\
Compress the define list ENV into a list of defined symbols only." (byte-code "	\"@@
*" [defs env new-defs nil mapcar (lambda (arg) (if (hif-lookup (car arg)) (car arg)))] 4))

(defun hide-ifdef-set-define-alist (name) "\
Set the association for NAME to hide-ifdef-env." (interactive "SSet define list: ") (byte-code "È	
!BB" [hide-ifdef-define-alist name hide-ifdef-env nil hif-compress-define-list] 3))

(defun hide-ifdef-use-define-alist (name) "\
Set hide-ifdef-env to the define list specified by NAME." (interactive "SUse define list: ") (byte-code "ň	
\"A\"	\"  )" [define-list name hide-ifdef-define-alist hide-ifdef-env hide-ifdef-hiding nil assoc mapcar (lambda (arg) (cons arg t)) error "No define list for %s" hide-ifdefs] 5))