1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099 |
- (eval-when-compile
- (let ((load-path
- (if (and (boundp 'byte-compile-dest-file)
- (stringp byte-compile-dest-file))
- (cons (file-name-directory byte-compile-dest-file) load-path)
- load-path)))
- (load "cc-bytecomp" nil t)))
- (cc-require 'cc-defs)
- (cc-bytecomp-defvar font-lock-mode)
- (cc-bytecomp-defvar c-new-BEG)
- (cc-bytecomp-defvar c-new-END)
- (cc-bytecomp-defun c-backward-token-1)
- (cc-bytecomp-defun c-beginning-of-statement-1)
- (cc-bytecomp-defun c-backward-sws)
- (defvar awk-mode-syntax-table
- (let ((st (make-syntax-table)))
- (modify-syntax-entry ?\\ "\\" st)
- (modify-syntax-entry ?\n "> " st)
- (modify-syntax-entry ?\r "> " st)
- (modify-syntax-entry ?\f "> " st)
- (modify-syntax-entry ?\# "< " st)
-
-
-
- (modify-syntax-entry ?/ "." st)
- (modify-syntax-entry ?* "." st)
- (modify-syntax-entry ?+ "." st)
- (modify-syntax-entry ?- "." st)
- (modify-syntax-entry ?= "." st)
- (modify-syntax-entry ?% "." st)
- (modify-syntax-entry ?< "." st)
- (modify-syntax-entry ?> "." st)
- (modify-syntax-entry ?& "." st)
- (modify-syntax-entry ?| "." st)
- (modify-syntax-entry ?_ "_" st)
- (modify-syntax-entry ?\' "." st)
- st)
- "Syntax table in use in AWK Mode buffers.")
- ;; This section defines regular expressions used in the analysis of AWK code.
- ;; N.B. In the following regexps, an EOL is either \n OR \r. This is because
- ;; Emacs has in the past used \r to mark hidden lines in some fashion (and
- ;; maybe still does).
- (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)")
- ;; Matches any escaped (with \) character-pair, including an escaped newline.
- (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)")
- ;; Matches any escaped (with \) character-pair, apart from an escaped newline.
- (defconst c-awk-comment-without-nl "#.*")
- ;; Matches an AWK comment, not including the terminating NL (if any). Note
- ;; that the "enclosing" (elisp) regexp must ensure the # is real.
- (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)")
- ;; Matches a newline, or the end of buffer.
- ;; "Space" regular expressions.
- (eval-and-compile
- (defconst c-awk-escaped-nl "\\\\[\n\r]"))
- ;; Matches an escaped newline.
- (eval-and-compile
- (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*")))
- ;; Matches a possibly empty sequence of escaped newlines. Used in
- ;; awk-font-lock-keywords.
- ;; (defconst c-awk-escaped-nls*-with-space*
- (eval-and-compile
- (defconst c-awk-escaped-nls*-with-space*
- (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*")))
- (defconst c-awk-blank-or-comment-line-re
- (concat "[ \t]*\\(#\\|\\\\?$\\)"))
- (defconst c-awk-harmless-char-re "[^_#/\"\\\\\n\r]")
- (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)")
- (defconst c-awk-harmless-string*-re
- (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*"))
- (defconst c-awk-harmless-string*-here-re
- (concat "\\=" c-awk-harmless-string*-re))
- (defconst c-awk-harmless-line-re
- (concat c-awk-harmless-string*-re
- "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob))
- (defconst c-awk-harmless-lines+-here-re
- (concat "\\=\\(" c-awk-harmless-line-re "\\)+"))
- (defconst c-awk-string-ch-re "[^\"\\\n\r]")
- (defconst c-awk-string-innards-re
- (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"))
- (defconst c-awk-string-without-end-here-re
- (concat "\\=_?\"" c-awk-string-innards-re))
- (defconst c-awk-one-line-possibly-open-string-re
- (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-non-eol-esc-pair-re "\\)*"
- "\\(\"\\|\\\\?$\\|\\'\\)"))
- (defconst c-awk-regexp-normal-re "[^[/\\\n\r]")
- (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*")
- (defconst c-awk-regexp-char-class-re
- "\\[:[a-z]+:\\]")
-
- (defconst c-awk-regexp-char-list-re
- (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
- "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
- "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
- (defconst c-awk-regexp-one-line-possibly-open-char-list-re
- (concat "\\[\\]?\\(" c-awk-non-eol-esc-pair-re "\\|" "[^]\n\r]" "\\)*"
- "\\(]\\|\\\\?$\\|\\'\\)"))
- (defconst c-awk-regexp-innards-re
- (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
- "\\|" c-awk-regexp-normal-re "\\)*"))
- (defconst c-awk-regexp-without-end-re
- (concat "/" c-awk-regexp-innards-re))
- (defconst c-awk-one-line-possibly-open-regexp-re
- (concat "/\\(" c-awk-non-eol-esc-pair-re
- "\\|" c-awk-regexp-one-line-possibly-open-char-list-re
- "\\|" c-awk-regexp-normal-re "\\)*"
- "\\(/\\|\\\\?$\\|\\'\\)"))
- (defconst c-awk-neutral-re
- "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)")
- (defconst c-awk-neutrals*-re
- (concat "\\(" c-awk-neutral-re "\\)*"))
- (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+")
- (defconst c-awk-div-sign-re
- (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/"))
- (defconst c-awk-non-arith-op-bra-re
- "[[\(&=:!><,?;'~|]")
- (defconst c-awk-regexp-sign-re
- (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/"))
- (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
- (defconst c-awk-one-line-non-syn-ws*-re
- (concat "\\([ \t]*"
- "\\(" c-awk-_-harmless-nonws-char-re "\\|"
- c-awk-non-eol-esc-pair-re "\\|"
- c-awk-one-line-possibly-open-string-re "\\|"
- c-awk-one-line-possibly-open-regexp-re
- "\\)"
- "\\)*"))
- (defun c-awk-after-if-for-while-condition-p (&optional do-lim)
-
-
-
-
-
-
-
-
-
-
- (and
- (eq (char-before) ?\))
- (save-excursion
- (let ((par-pos (c-safe (scan-lists (point) -1 0))))
- (when par-pos
- (goto-char par-pos)
- (c-backward-token-1)
- (or (looking-at "\\(if\\|for\\)\\>\\([^_]\\|$\\)")
- (and (looking-at "while\\>\\([^_]\\|$\\)")
- (not (eq (c-beginning-of-statement-1 do-lim)
- 'beginning)))))))))
- (defun c-awk-after-function-decl-param-list ()
-
-
-
- (and (eq (char-before) ?\))
- (save-excursion
- (let ((par-pos (c-safe (scan-lists (point) -1 0))))
- (when par-pos
- (goto-char par-pos)
- (c-backward-token-1)
- (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*\\>")
- (progn (c-backward-token-1)
- (looking-at "func\\(tion\\)?\\>"))))))))
- (defun c-awk-after-continue-token ()
- (save-excursion
- (c-backward-token-1)
- (if (and (looking-at "[&|]") (not (bobp)))
- (backward-char))
- (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>")))
- (defun c-awk-after-rbrace-or-statement-semicolon ()
-
-
-
-
- (or (eq (char-before) ?\})
- (and
- (eq (char-before) ?\
- (save-excursion
- (let ((par-pos (c-safe (scan-lists (point) -1 1))))
- (when par-pos
- (goto-char par-pos)
- (not (and (looking-at "(")
- (c-backward-token-1)
- (looking-at "for\\>")))))))))
- (defun c-awk-back-to-contentful-text-or-NL-prop ()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((nl-prop nil)
- bol-pos bsws-pos)
- (while
- (and
- (not (bobp))
- (not (setq nl-prop (c-get-char-property (1- (point)) 'c-awk-NL-prop)))
- (progn (setq bol-pos (c-point 'bopl))
- (setq bsws-pos (point))
-
-
-
-
- (c-backward-syntactic-ws bol-pos)
- (or (/= (point) bsws-pos)
- (progn (setq nl-prop ?\$)
- (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop)
- nil)))
-
-
- (progn
- (if (looking-at "[ \t]*\\\\+$")
- (if (progn
- (end-of-line)
- (search-backward-regexp
- "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\$"
- bol-pos t))
- (progn (end-of-line)
- (backward-char)
- (c-backward-syntactic-ws bol-pos))
- (end-of-line)))
- (bolp))))
- nl-prop))
- (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim)
-
-
-
-
-
-
-
-
-
-
-
-
-
- (save-excursion
- (save-match-data
- (beginning-of-line)
- (let* ((pos (point))
- (nl-prop (c-awk-back-to-contentful-text-or-NL-prop)))
-
-
-
-
- (when (not (bolp))
- (setq nl-prop
- (cond
-
- ((or (c-awk-after-if-for-while-condition-p do-lim)
- (c-awk-after-function-decl-param-list)
- (c-awk-after-continue-token))
- ?\{)
-
- ((and (looking-at "[ \t]*\\\\$")
- (not (c-awk-after-rbrace-or-statement-semicolon)))
- ?\\)
-
- ((memq (char-before) '(?\; ?\})) ?\})
- (t ?\$)))
- (end-of-line)
- (c-put-char-property (point) 'c-awk-NL-prop nl-prop)
- (forward-line))
-
-
- (while (< (point) pos)
- (cond
- ((memq nl-prop '(?\} ?\$ nil)) (setq nl-prop ?\#))
- ((eq nl-prop ?\\)
- (if (not (looking-at "[ \t]*\\\\$")) (setq nl-prop ?\$)))
-
- )
- (forward-line)
- (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop))
- nl-prop))))
- (defun c-awk-get-NL-prop-prev-line (&optional do-lim)
-
-
-
-
-
- (if (bobp)
- nil
- (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop)
- (c-awk-calculate-NL-prop-prev-line do-lim))))
- (defun c-awk-get-NL-prop-cur-line (&optional do-lim)
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((extra-nl nil))
- (end-of-line)
- (when (= (forward-line) 1)
- (insert-char ?\n 1)
- (setq extra-nl t))
- (prog1 (c-awk-get-NL-prop-prev-line do-lim)
- (if extra-nl (delete-char -1))))))
- (defsubst c-awk-prev-line-incomplete-p (&optional do-lim)
-
-
-
-
- (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{)))
- (defsubst c-awk-cur-line-incomplete-p (&optional do-lim)
-
-
-
-
- (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{)))
- (defun c-awk-at-vsemi-p (&optional pos)
-
- (save-excursion
- (let (nl-prop
- (pos-or-point (progn (if pos (goto-char pos)) (point))))
- (forward-line 0)
- (search-forward-regexp c-awk-one-line-non-syn-ws*-re)
- (and (eq (point) pos-or-point)
- (progn
- (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\)
- (eq (forward-line) 0)
- (looking-at c-awk-blank-or-comment-line-re)))
- (eq nl-prop ?\$))))))
- (defun c-awk-vsemi-status-unknown-p ()
-
-
-
-
-
- (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop)))
- (defun c-awk-clear-NL-props (beg end)
-
-
-
-
-
-
- (save-restriction
- (widen)
- (c-clear-char-properties beg (point-max) 'c-awk-NL-prop)))
- (defun c-awk-unstick-NL-prop ()
-
-
-
-
- (if (and (boundp 'text-property-default-nonsticky)
- (not (assoc 'c-awk-NL-prop text-property-default-nonsticky)))
- (setq text-property-default-nonsticky
- (cons '(c-awk-NL-prop . t) text-property-default-nonsticky))))
- (defun c-awk-beginning-of-logical-line (&optional pos)
- (if pos (goto-char pos))
- (forward-line 0)
- (while (and (> (point) (point-min))
- (eq (char-before (1- (point))) ?\\))
- (forward-line -1))
- (point))
- (defun c-awk-beyond-logical-line (&optional pos)
- (save-excursion
- (if pos (goto-char pos))
- (end-of-line)
- (while (and (< (point) (point-max))
- (eq (char-before) ?\\))
- (end-of-line 2))
- (if (< (point) (point-max))
- (1+ (point))
- (point))))
- (defun c-awk-set-string-regexp-syntax-table-properties (beg end)
- (if (eq (char-after beg) ?_) (setq beg (1+ beg)))
-
- (cond ((eq end (point-max))
- (c-put-char-property beg 'syntax-table '(15)))
- ((/= (char-after beg) (char-after end))
- (c-put-char-property beg 'syntax-table '(15))
- (c-put-char-property end 'syntax-table '(15)))
- ((eq (char-after beg) ?/)
- (c-put-char-property beg 'syntax-table '(7))
- (c-put-char-property end 'syntax-table '(7)))
- (t))
-
- (save-excursion
- (goto-char (1+ beg))
- (or (eobp)
- (while (search-forward "\"" end t)
- (c-put-char-property (1- (point)) 'syntax-table '(1))))))
- (defun c-awk-syntax-tablify-string ()
-
-
-
-
-
-
-
- (search-forward-regexp c-awk-string-without-end-here-re nil t)
- (c-awk-set-string-regexp-syntax-table-properties
- (match-beginning 0) (match-end 0))
- (cond ((looking-at "\"")
- (forward-char)
- t)
- ((looking-at "[\n\r]")
- (forward-char)
- nil)
- (t nil)))
- (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div)
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((/point (point)))
- (goto-char anchor)
-
- (if (if anchor-state-/div
- (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t))
- (search-forward-regexp c-awk-div-sign-re (1+ /point) t))
-
- (progn (goto-char (1+ /point)) nil)
-
-
- (goto-char /point)
- (search-forward-regexp c-awk-regexp-without-end-re)
- (c-awk-set-string-regexp-syntax-table-properties
- (match-beginning 0) (match-end 0))
- (cond ((looking-at "/")
- (forward-char)
- t)
- ((looking-at "[\n\r]")
- (forward-char)
- nil)
- (t nil)))))
- (defun c-awk-set-syntax-table-properties (lim)
- (let (anchor
- (anchor-state-/div nil))
- (c-awk-beginning-of-logical-line)
- (c-clear-char-properties (point) lim 'syntax-table)
-
- (while (progn
-
- (if (search-forward-regexp c-awk-harmless-lines+-here-re nil t)
- (setq anchor-state-/div nil))
- (< (point) lim))
- (setq anchor (point))
- (search-forward-regexp c-awk-harmless-string*-here-re nil t)
-
-
- (setq anchor-state-/div
- (if (looking-at "_?\"")
- (c-awk-syntax-tablify-string)
- (c-awk-syntax-tablify-/ anchor anchor-state-/div))))
- nil))
- (defvar c-awk-old-ByLL 0)
- (make-variable-buffer-local 'c-awk-old-Byll)
- (defun c-awk-record-region-clear-NL (beg end)
- (c-save-buffer-state ()
- (setq c-awk-old-ByLL (c-awk-beyond-logical-line end))
- (c-save-buffer-state nil
- (c-awk-clear-NL-props end (point-max)))))
- (defun c-awk-end-of-change-region (beg end old-len)
-
-
-
-
- (max (+ (- c-awk-old-ByLL old-len) (- end beg))
- (c-awk-beyond-logical-line end)))
- (defun c-awk-extend-and-syntax-tablify-region (beg end old-len)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (c-save-buffer-state ()
- (setq c-new-END (c-awk-end-of-change-region beg end old-len))
- (setq c-new-BEG (c-awk-beginning-of-logical-line beg))
- (goto-char c-new-BEG)
- (c-awk-set-syntax-table-properties c-new-END)))
- (defconst awk-font-lock-keywords
- (eval-when-compile
- (list
-
- '("^\\s *\\(func\\(tion\\)?\\)\\>\\s *\\(\\sw+\\)?"
- (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
-
-
- (cons
- (concat "\\<"
- (regexp-opt
- '("ARGC" "ARGIND" "ARGV" "BINMODE" "CONVFMT" "ENVIRON"
- "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE"
- "LINT" "NF" "NR" "OFMT" "OFS" "ORS" "PROCINFO" "RLENGTH"
- "RS" "RSTART" "RT" "SUBSEP" "TEXTDOMAIN") t) "\\>")
- 'font-lock-variable-name-face)
-
-
-
-
-
-
-
-
-
-
- '("\\(\"/dev/\\(fd/[0-9]+\\|p\\(\\(\\(gr\\)?p\\)?id\\)\\|\
- std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
- \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)"
- (1 font-lock-variable-name-face t)
- (8 font-lock-variable-name-face t t))
-
-
-
-
-
- '("\\(\"/inet/\\(\\(raw\\|\\(tc\\|ud\\)p\\)/lport/rhost/rport\\)\\)\\>\
- \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)"
- (1 font-lock-variable-name-face t)
- (6 font-lock-variable-name-face t t))
-
- (concat "\\<"
- (regexp-opt
- '("BEGIN" "END" "break" "case" "continue" "default" "delete"
- "do" "else" "exit" "for" "getline" "if" "in" "next"
- "nextfile" "return" "switch" "while")
- t) "\\>")
-
- `(eval . (list
- ,(concat
- "\\<"
- (regexp-opt
- '("adump" "and" "asort" "atan2" "bindtextdomain" "close"
- "compl" "cos" "dcgettext" "exp" "extension" "fflush"
- "gensub" "gsub" "index" "int" "length" "log" "lshift"
- "match" "mktime" "or" "print" "printf" "rand" "rshift"
- "sin" "split" "sprintf" "sqrt" "srand" "stopme"
- "strftime" "strtonum" "sub" "substr" "system"
- "systime" "tolower" "toupper" "xor") t)
- "\\>")
- 0 c-preprocessor-face-name))
-
-
-
-
-
-
- `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "\\s "
- c-awk-escaped-nls*-with-space* "(")
- (0 'font-lock-warning-face))
-
- '("\\\\\\s +$" 0 font-lock-warning-face t)
-
- '("\\s|" 0 font-lock-warning-face t nil)
-
- '("\\(_\\)\\s|" 1 font-lock-warning-face)
- '("\\(_\\)\\s\"" 1 font-lock-string-face)
- ))
- "Default expressions to highlight in AWK mode.")
- (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"")
- (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$")
- (defconst c-awk-harmless-pattern-characters*
- (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*"))
- (defun c-awk-at-statement-end-p ()
-
-
-
-
- (and (not (bobp))
- (save-excursion
- (backward-char)
- (or (looking-at "[};]")
- (and (memq (c-awk-get-NL-prop-cur-line) '(?\$ ?\\))
- (looking-at
- (eval-when-compile
- (concat "[^ \t\n\r\\]" c-awk-escaped-nls*-with-space*
- "[#\n\r]"))))))))
- (defun c-awk-beginning-of-defun (&optional arg)
- "Move backward to the beginning of an AWK \"defun\". With ARG, do it that
- many times. Negative arg -N means move forward to Nth following beginning of
- defun. Returns t unless search stops due to beginning or end of buffer.
- By a \"defun\" is meant either a pattern-action pair or a function. The start
- of a defun is recognized as code starting at column zero which is neither a
- closing brace nor a comment nor a continuation of the previous line. Unlike
- in some other modes, having an opening brace at column 0 is neither necessary
- nor helpful.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (interactive "p")
- (or arg (setq arg 1))
- (save-match-data
- (c-save-buffer-state
- nil
- (let ((found t))
- (if (>= arg 0)
-
- (while (and found (> arg 0) (not (eq (point) (point-min))))
-
-
- (while (and (setq found (search-backward-regexp
- "^[^#} \t\n\r]" (point-min) 'stop-at-limit))
- (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
- (setq arg (1- arg)))
-
- (if (not (eq (point) (point-max))) (forward-char 1))
- (while (and found (< arg 0) (not (eq (point) (point-max))))
- (while (and (setq found (search-forward-regexp
- "^[^#} \t\n\r]" (point-max) 'stop-at-limit))
- (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
- (setq arg (1+ arg)))
- (if found (goto-char (match-beginning 0))))
- (eq arg 0)))))
- (defun c-awk-forward-awk-pattern ()
-
-
-
-
-
-
-
- (while
- (progn
- (search-forward-regexp c-awk-harmless-pattern-characters*)
- (if (looking-at "#") (end-of-line))
- (cond
- ((eobp) nil)
- ((looking-at "[{;]") nil)
- ((eolp)
- (if (c-awk-cur-line-incomplete-p)
- (forward-line)
- nil))
- ((search-forward-regexp c-awk-terminated-regexp-or-string-here-re nil t))
- ((search-forward-regexp c-awk-unterminated-regexp-or-string-here-re nil t))
- ((looking-at "/") (forward-char) t)))))
- (defun c-awk-end-of-defun1 ()
-
-
-
- (c-awk-forward-awk-pattern)
- (cond
- ((looking-at "{") (goto-char (scan-sexps (point) 1)))
- ((looking-at ";") (forward-char))
- ((eolp))
- (t (error "c-awk-end-of-defun1: Failure of c-awk-forward-awk-pattern")))
- (point))
- (defun c-awk-beginning-of-defun-p ()
-
-
-
-
- (and (looking-at "^[^#} \t\n\r]")
- (not (c-awk-prev-line-incomplete-p))))
- (defun c-awk-end-of-defun (&optional arg)
- "Move forward to next end of defun. With argument, do it that many times.
- Negative argument -N means move back to Nth preceding end of defun.
- An end of a defun occurs right after the closing brace that matches the
- opening brace at its start, or immediately after the AWK pattern when there is
- no explicit action; see function `c-awk-beginning-of-defun'.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (interactive "p")
- (or arg (setq arg 1))
- (save-match-data
- (c-save-buffer-state
- nil
- (let ((start-point (point)) end-point)
-
-
-
-
-
- (when (> arg 0)
-
- (if (not (c-awk-beginning-of-defun-p))
- (when (not (c-awk-beginning-of-defun 1))
- (goto-char start-point)
- (c-awk-beginning-of-defun -1)))
-
- (while (and (not (eobp))
- (c-awk-end-of-defun1)
- (if (> (point) start-point) (setq arg (1- arg)) t)
- (> arg 0)
- (c-awk-beginning-of-defun -1))))
- (when (< arg 0)
- (setq end-point start-point)
- (while (and (not (bobp))
- (c-awk-beginning-of-defun 1)
- (if (< (setq end-point (if (bobp) (point)
- (save-excursion (c-awk-end-of-defun1))))
- start-point)
- (setq arg (1+ arg)) t)
- (< arg 0)))
- (goto-char (min start-point end-point)))))))
- (cc-provide 'cc-awk)
|