• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching defs:keywords

65 ;; regexp (i.e., keywords and everything else) passes.  There are actually
70 ;; buffer according to the variable `font-lock-syntactic-keywords'. It is
89 ;; the variable `font-lock-keywords'. It involves searching for given regexps
119 ;; See the documentation for the variable `font-lock-keywords'.
121 ;; Efficient regexps for use as MATCHERs for `font-lock-keywords' and
122 ;; `font-lock-syntactic-keywords' can be generated via the function
130 ;; `font-lock-add-keywords'. For example, say in some C
134 ;; (font-lock-add-keywords 'c-mode '("\\<\\(and\\|or\\|not\\)\\>"))
150 ;; (defvar foo-font-lock-keywords
158 ;; '(foo-font-lock-keywords t))))
171 ;; (defvar bar-font-lock-keywords
179 ;; '(bar-font-lock-keywords nil t))
199 ;; keywords, should be highlighted with the same face, etc.
207 ;; Don't use it to, say, highlight keywords in commented out code or strings.
294 ;; We now allow a FACENAME in `font-lock-keywords' to be any expression that
310 "Face name to use for keywords.")
342 (defvar font-lock-keywords nil
343 "A list of the keywords to highlight.
346 A user-level keywords list is what a major mode or the user would
350 `font-lock-add-keywords' or `font-lock-remove-keywords' with MODE = nil.
352 Each element in a user-level keywords list should have one of these forms:
455 A compiled keywords list starts with t. It is produced internal
456 by `font-lock-compile-keywords' from a user-level keywords list.
457 Its second element is the user-level keywords list that was
459 user-level keywords, but normally their values have been
462 (defvar font-lock-keywords-alist nil
463 "Alist of additional `font-lock-keywords' elements for major modes.
467 `font-lock-keywords' when Font Lock is turned on in major mode MODE.
470 `font-lock-keywords'. If it is `set', they are used to replace the
471 value of `font-lock-keywords'. If HOW is any other non-nil value,
474 This is normally set via `font-lock-add-keywords' and
475 `font-lock-remove-keywords'.")
476 (put 'font-lock-keywords-alist 'risky-local-variable t)
478 (defvar font-lock-removed-keywords-alist nil
479 "Alist of `font-lock-keywords' elements to be removed for major modes.
482 removes the elements in the list KEYWORDS from `font-lock-keywords'
485 This is normally set via `font-lock-add-keywords' and
486 `font-lock-remove-keywords'.")
488 (defvar font-lock-keywords-only nil
492 (defvar font-lock-keywords-case-fold-search nil
493 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
495 (make-variable-buffer-local 'font-lock-keywords-case-fold-search)
498 "Point up to which `font-lock-syntactic-keywords' has been applied.
511 (defvar font-lock-syntactic-keywords nil
512 "A list of the syntactic keywords to put syntax properties on.
516 See `font-lock-keywords' for a description of the form of this list;
525 Here are two examples of elements of `font-lock-syntactic-keywords'
594 "Whether font-lock should cater to multiline keywords.
654 (defun font-lock-add-keywords (mode keywords &optional how)
658 or nil. If nil, highlighting keywords are added for the current buffer.
659 KEYWORDS should be a list; see the variable `font-lock-keywords'.
667 (font-lock-add-keywords 'c-mode
672 comments, and to fontify `and', `or' and `not' words as keywords.
674 The above procedure will only add the keywords for C mode, not
682 (font-lock-add-keywords nil
687 The above procedure may fail to add keywords to derived modes if
696 ;; `font-lock-keywords-alist' so `font-lock-set-defaults' uses them.
697 (let ((spec (cons keywords how)) cell)
698 (if (setq cell (assq mode font-lock-keywords-alist))
702 (push (list mode spec) font-lock-keywords-alist)))
703 ;; Make sure that `font-lock-removed-keywords-alist' does not
704 ;; contain the new keywords.
705 (font-lock-update-removed-keyword-alist mode keywords how))
707 ;; Otherwise set or add the keywords now.
711 (let ((was-compiled (eq (car font-lock-keywords) t)))
712 ;; Bring back the user-level (uncompiled) keywords.
714 (setq font-lock-keywords (cadr font-lock-keywords)))
717 (setq font-lock-keywords keywords)
718 (font-lock-remove-keywords nil keywords) ;to avoid duplicates
719 (let ((old (if (eq (car-safe font-lock-keywords) t)
720 (cdr font-lock-keywords)
721 font-lock-keywords)))
722 (setq font-lock-keywords (if how
723 (append old keywords)
724 (append keywords old)))))
725 ;; If the keywords were compiled before, compile them again.
727 (setq font-lock-keywords
728 (font-lock-compile-keywords font-lock-keywords)))))))
730 (defun font-lock-update-removed-keyword-alist (mode keywords how)
731 "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE."
732 ;; When font-lock is enabled first all keywords in the list
733 ;; `font-lock-keywords-alist' are added, then all keywords in the
734 ;; list `font-lock-removed-keywords-alist' are removed. If a
736 ;; removed from the removed-keywords list. Otherwise the second add
738 (let ((cell (assq mode font-lock-removed-keywords-alist)))
741 ;; A new set of keywords is defined. Forget all about
742 ;; our old keywords that should be removed.
743 (setq font-lock-removed-keywords-alist
744 (delq cell font-lock-removed-keywords-alist))
745 ;; Delete all previously removed keywords.
746 (dolist (kword keywords)
750 (setq font-lock-removed-keywords-alist
751 (delq cell font-lock-removed-keywords-alist)))))))
756 ;; (I) The keywords are removed from a major mode.
758 ;; `font-lock-add-keywords'), global, or both.
760 ;; (a) In the local case we remove the keywords from the variable
761 ;; `font-lock-keywords-alist'.
763 ;; (b) The actual global keywords are not known at this time.
764 ;; All keywords are added to `font-lock-removed-keywords-alist',
765 ;; when font-lock is enabled those keywords are removed.
767 ;; Note that added keywords are taken out of the list of removed
768 ;; keywords. This ensure correct operation when the same keyword
771 ;; (II) The keywords are removed from the current buffer.
772 (defun font-lock-remove-keywords (mode keywords)
776 or nil. If nil, highlighting keywords are removed for the current buffer.
785 (dolist (keyword keywords)
786 (let ((top-cell (assq mode font-lock-keywords-alist)))
788 ;; `font-lock-keywords-alist'.
791 ;; `keywords-list-how-pair' is a cons with a list of
792 ;; keywords in the car top-cell and the original how
798 ;; should be deleted then previously deleted keywords
809 (setq font-lock-keywords-alist
810 (delq top-cell font-lock-keywords-alist))))
812 (let ((cell (assq mode font-lock-removed-keywords-alist)))
817 font-lock-removed-keywords-alist))))))
821 (let ((was-compiled (eq (car font-lock-keywords) t)))
822 ;; Bring back the user-level (uncompiled) keywords.
824 (setq font-lock-keywords (cadr font-lock-keywords)))
827 (setq font-lock-keywords (copy-sequence font-lock-keywords))
828 (dolist (keyword keywords)
829 (setq font-lock-keywords
830 (delete keyword font-lock-keywords)))
832 ;; If the keywords were compiled before, compile them again.
834 (setq font-lock-keywords
835 (font-lock-compile-keywords font-lock-keywords)))))))
904 (not font-lock-keywords-only))
980 ;; `font-lock-fontify-keywords-region' for the normal regexp fontification
1111 (or parse-sexp-lookup-properties font-lock-syntactic-keywords))
1136 (when font-lock-syntactic-keywords
1137 (font-lock-fontify-syntactic-keywords-region beg end))
1138 (unless font-lock-keywords-only
1140 (font-lock-fontify-keywords-region beg end loudly))
1144 ;; The following must be rethought, since keywords can override fontification.
1145 ;; ;; Now scan for keywords, but not if we are inside a comment now.
1146 ;; (or (and (not font-lock-keywords-only)
1150 ;; (font-lock-fontify-keywords-region beg end))
1161 (if font-lock-syntactic-keywords
1261 ;; Make sure we have the right `font-lock-keywords' etc.
1368 ;; `font-lock-syntactic-keywords' of course, (b) they are all `defun' as speed
1377 see `font-lock-syntactic-keywords'."
1405 (defun font-lock-fontify-syntactic-anchored-keywords (keywords limit)
1407 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
1409 (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
1411 (pre-match-value (eval (nth 1 keywords))))
1427 (eval (nth 2 keywords))))
1429 (defun font-lock-fontify-syntactic-keywords-region (start end)
1430 "Fontify according to `font-lock-syntactic-keywords' between START and END.
1437 ;; If `font-lock-syntactic-keywords' is a symbol, get the real keywords.
1438 (when (symbolp font-lock-syntactic-keywords)
1439 (setq font-lock-syntactic-keywords (font-lock-eval-keywords
1440 font-lock-syntactic-keywords)))
1441 ;; If `font-lock-syntactic-keywords' is not compiled, compile it.
1442 (unless (eq (car font-lock-syntactic-keywords) t)
1443 (setq font-lock-syntactic-keywords (font-lock-compile-keywords
1444 font-lock-syntactic-keywords
1447 (let ((case-fold-search font-lock-keywords-case-fold-search)
1448 (keywords (cddr font-lock-syntactic-keywords))
1450 (while keywords
1452 (setq keyword (car keywords) matcher (car keyword))
1458 ;; specific highlights or more keywords anchored to `matcher'.
1463 (font-lock-fontify-syntactic-anchored-keywords (car highlights)
1466 (setq keywords (cdr keywords)))))
1527 HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'."
1563 (defsubst font-lock-fontify-anchored-keywords (keywords limit)
1565 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
1567 (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
1570 (pre-match-value (eval (nth 1 keywords))))
1595 (eval (nth 2 keywords))))
1597 (defun font-lock-fontify-keywords-region (start end &optional loudly)
1598 "Fontify according to `font-lock-keywords' between START and END.
1601 (unless (eq (car font-lock-keywords) t)
1602 (setq font-lock-keywords
1603 (font-lock-compile-keywords font-lock-keywords)))
1604 (let ((case-fold-search font-lock-keywords-case-fold-search)
1605 (keywords (cddr font-lock-keywords))
1610 ;; Fontify each item in `font-lock-keywords' from `start' to `end'.
1611 (while keywords
1616 (setq keyword (car keywords) matcher (car keyword))
1641 ;; specific highlights or more keywords anchored to `matcher'.
1647 (font-lock-fontify-anchored-keywords (car highlights) end)
1652 (setq keywords (cdr keywords)))
1660 (defun font-lock-compile-keywords (keywords &optional syntactic-keywords)
1663 `font-lock-keywords' doc string.
1664 If SYNTACTIC-KEYWORDS is non-nil, it means these keywords are used for
1665 `font-lock-syntactic-keywords' rather than for `font-lock-keywords'."
1670 ;; global value of font-lock-keywords and break highlighting in many
1672 (error "Font-lock trying to use keywords before setting them up"))
1673 (if (eq (car-safe keywords) t)
1674 keywords
1675 (setq keywords
1676 (cons t (cons keywords
1677 (mapcar 'font-lock-compile-keyword keywords))))
1678 (if (and (not syntactic-keywords)
1687 (nconc keywords
1698 keywords))
1719 (defun font-lock-eval-keywords (keywords)
1721 (if (listp keywords)
1722 keywords
1723 (font-lock-eval-keywords (if (fboundp keywords)
1724 (funcall keywords)
1725 (eval keywords)))))
1734 (defun font-lock-choose-keywords (keywords level)
1738 (cond ((not (and (listp keywords) (symbolp (car keywords))))
1739 keywords)
1741 (or (nth level keywords) (car (last keywords))))
1743 (car (last keywords)))
1745 (car keywords))))
1765 (keywords
1766 (font-lock-choose-keywords (nth 0 defaults)
1768 (local (cdr (assq major-mode font-lock-keywords-alist)))
1769 (removed-keywords
1770 (cdr-safe (assq major-mode font-lock-removed-keywords-alist))))
1774 (set (make-local-variable 'font-lock-keywords-only) t))
1777 (set (make-local-variable 'font-lock-keywords-case-fold-search) t))
1796 ;; Set up `font-lock-keywords' last because its value might depend
1797 ;; on other settings (e.g. font-lock-compile-keywords uses
1799 (set (make-local-variable 'font-lock-keywords)
1800 (font-lock-eval-keywords keywords))
1803 (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
1805 (when removed-keywords
1806 (font-lock-remove-keywords nil removed-keywords))
1807 ;; Now compile the keywords.
1808 (unless (eq (car font-lock-keywords) t)
1809 (setq font-lock-keywords
1810 (font-lock-compile-keywords font-lock-keywords))))))
1875 "Font Lock mode face used to highlight keywords."
2053 ;; (let ((keywords (or (nth 0 font-lock-defaults)
2057 ;; (if (or (symbolp keywords) (= (length keywords) 1))
2060 ;; (setq level (1- (length keywords))))
2063 ;; (setq level (- (length keywords)
2064 ;; (length (member (eval (car keywords))
2065 ;; (mapcar 'eval (cdr keywords))))))))
2067 ;; (< level (1- (length keywords))))))))
2102 This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
2130 ;; `cpp-font-lock-keywords' is handy for modes for the files.
2136 ;; `cpp-font-lock-keywords-source-directives' is calculated from:
2142 (defconst cpp-font-lock-keywords-source-directives
2144 "Regular expressoin used in `cpp-font-lock-keywords'.")
2146 ;; `cpp-font-lock-keywords-source-depth' is calculated from:
2152 (defconst cpp-font-lock-keywords-source-depth 0
2153 "An integer representing regular expression depth of `cpp-font-lock-keywords-source-directives'.
2154 Used in `cpp-font-lock-keywords'.")
2156 (defconst cpp-font-lock-keywords
2157 (let* ((directives cpp-font-lock-keywords-source-directives)
2158 (directives-depth cpp-font-lock-keywords-source-depth))
2203 (defconst lisp-font-lock-keywords-1
2233 (defconst lisp-font-lock-keywords-2
2234 (append lisp-font-lock-keywords-1
2290 ;; ELisp and CLisp `&' keywords as types.
2316 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1