Function: hif-find-define
hif-find-define is an interactive and byte-compiled function defined
in hideif.el.gz.
Signature
(hif-find-define &optional MIN MAX)
Documentation
Parse texts and retrieve all defines within the region MIN and MAX.
Interactively, MIN is position of point and MAX is the end of the buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/hideif.el.gz
(defun hif-find-define (&optional min max)
"Parse texts and retrieve all defines within the region MIN and MAX.
Interactively, MIN is position of point and MAX is the end of the buffer."
(interactive)
(and min (goto-char min))
(and (re-search-forward hif-define-regexp max t)
(or
(let* ((defining (string= "define" (match-string 2)))
(name (and (re-search-forward hif-macroref-regexp max t)
(match-string 1)))
(parmlist (or (and (or (match-string 3) ; First arg id found
(match-string 6)) ; '...' found
(delq 'hif-space
(hif-parse-macro-arglist
(match-string 2))))
(and (match-string 2) ; empty arglist
(list nil)))))
(if defining
;; Ignore name (still need to return 't), or define the name
(or (and hide-ifdef-exclude-define-regexp
(string-match hide-ifdef-exclude-define-regexp
name))
(let* ((start (point))
(end (progn (hif-end-of-line) (point)))
(hif-simple-token-only nil) ; Dynamic binding
(tokens
(and name
(prog1 t
(incf hif-verbose-define-count)
;; only show 1/50 to not slow down to much
(if (and hide-ifdef-verbose
(= (% hif-verbose-define-count 50) 1))
(message "[Line %d] defining %S"
(line-number-at-pos (point))
(substring-no-properties name))))
;; `hif-simple-token-only' is set/clear
;; only in this block
(condition-case nil
;; Prevent C statements like
;; 'do { ... } while (0)'
(hif-tokenize start end)
(error
;; We can't just return nil here since
;; this will stop hideif from searching
;; for more #defines.
(setq hif-simple-token-only t)
(replace-regexp-in-string
"^[ \t]*\\|[ \t]*$" ""
(buffer-substring-no-properties
start end))))))
;; For simple tokens we save only the parsed result;
;; otherwise we save the tokens and parse it after
;; parameter replacement
(expr (and tokens
;; `hif-simple-token-only' is checked only
;; here.
(or (and (null parmlist)
hif-simple-token-only
(listp tokens)
(= (length tokens) 1)
(hif-parse-exp tokens))
`(hif-define-macro ,parmlist
,tokens))))
(SA (and name
(assq (intern name) hide-ifdef-env))))
(and name
(if SA
(or (setcdr SA expr) t)
;; Lazy evaluation, eval only if `hif-lookup' find it.
;; Define it anyway, even if nil it's still in list
;; and therefore considered defined.
(push (cons (intern name) expr) hide-ifdef-env)))))
;; #undef
(and name
(intern-soft name)
(hif-undefine-symbol (intern name)))
t)))
t))