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

Lines Matching defs:patterns

37 ;;  file patterns is turned on).
64 ;; To enable the use of patterns found in files (presumably placed
67 ;; (setq hi-lock-file-patterns-policy 'ask)
70 ;; `ask' with a function that returns t if patterns should be read.
76 ;; (define-key hi-lock-map "\C-zi" 'hi-lock-find-patterns)
80 ;; (define-key hi-lock-map "\C-zb" 'hi-lock-write-interactive-patterns))
85 ;; Sample file patterns:
97 "Interactively add and remove font-lock patterns for highlighting text."
101 (defcustom hi-lock-file-patterns-range 10000
102 "Limit of search in a buffer for hi-lock patterns.
103 When a file is visited and hi-lock mode is on, patterns starting
104 up to this limit are added to font-lock's patterns. See documentation
105 of functions `hi-lock-mode' and `hi-lock-find-patterns'."
113 hi-lock patterns will only be applied over a range of
122 For security reasons since font lock patterns can specify function
127 (defcustom hi-lock-file-patterns-policy 'ask
128 "Specify when hi-lock should use patterns found in file.
129 If `ask', prompt when patterns found in buffer; if bound to a function,
130 use patterns when function returns t (function is called with patterns
132 patterns."
133 :type '(choice (const :tag "Do not use file patterns" never)
134 (const :tag "Ask about file patterns" ask)
135 (function :tag "Function to check file patterns"))
140 (put 'hi-lock-file-patterns-policy 'risky-local-variable t)
205 (defvar hi-lock-file-patterns nil
208 (defvar hi-lock-interactive-patterns nil
221 (defvar hi-lock-file-patterns-prefix "Hi-lock"
222 "Search target for finding hi-lock patterns at top of file.")
235 (make-variable-buffer-local 'hi-lock-interactive-patterns)
236 (put 'hi-lock-interactive-patterns 'permanent-local t)
239 (make-variable-buffer-local 'hi-lock-file-patterns)
240 (put 'hi-lock-file-patterns 'permanent-local t)
260 :enable hi-lock-interactive-patterns))
262 (define-key-after hi-lock-menu [hi-lock-write-interactive-patterns]
263 '(menu-item "Patterns to Buffer" hi-lock-write-interactive-patterns
265 :enable hi-lock-interactive-patterns))
267 (define-key-after hi-lock-menu [hi-lock-find-patterns]
268 '(menu-item "Patterns from Buffer" hi-lock-find-patterns
269 :help "Use patterns (if any) near top of buffer."))
274 (define-key hi-lock-map "\C-xwi" 'hi-lock-find-patterns)
279 (define-key hi-lock-map "\C-xwb" 'hi-lock-write-interactive-patterns)
285 "Toggle minor mode for interactively adding font-lock highlighting patterns.
308 \\[hi-lock-write-interactive-patterns]
310 be read the next time file is loaded or when the \\[hi-lock-find-patterns] command
312 (See `font-lock-keywords'.) They may be edited and re-loaded with \\[hi-lock-find-patterns],
314 loaded the patterns are read if `hi-lock-file-patterns-policy is
316 `hi-lock-file-patterns-policy' is bound to a function and that
319 \\[hi-lock-find-patterns]
320 Re-read patterns stored in buffer (in the format produced by \\[hi-lock-write-interactive-patterns]).
322 When hi-lock is started and if the mode is not excluded or patterns
326 where FOO is a list of patterns. These are added to the font lock
327 keywords already present. The patterns must start before position
328 \(number of characters into buffer) `hi-lock-file-patterns-range'.
333 :lighter (:eval (if (or hi-lock-interactive-patterns
334 hi-lock-file-patterns)
361 (hi-lock-find-patterns)
364 (when (or hi-lock-interactive-patterns
365 hi-lock-file-patterns)
366 (when hi-lock-interactive-patterns
367 (font-lock-remove-keywords nil hi-lock-interactive-patterns)
368 (setq hi-lock-interactive-patterns nil))
369 (when hi-lock-file-patterns
370 (font-lock-remove-keywords nil hi-lock-file-patterns)
371 (setq hi-lock-file-patterns nil))
461 interactive functions. \(See `hi-lock-interactive-patterns'.\)
482 hi-lock-interactive-patterns))))
490 hi-lock-interactive-patterns)))
491 (unless hi-lock-interactive-patterns
495 hi-lock-interactive-patterns nil t
496 (car (car hi-lock-interactive-patterns))
498 (let ((keyword (assoc regexp hi-lock-interactive-patterns)))
501 (setq hi-lock-interactive-patterns
502 (delq keyword hi-lock-interactive-patterns))
508 (defun hi-lock-write-interactive-patterns ()
509 "Write interactively added patterns, if any, into buffer at point.
511 Interactively added patterns are those normally specified using
513 be found in variable `hi-lock-interactive-patterns'."
515 (if (null hi-lock-interactive-patterns)
516 (error "There are no interactive patterns"))
521 hi-lock-file-patterns-prefix
523 hi-lock-interactive-patterns)
525 (when (> (point) hi-lock-file-patterns-range)
571 (unless (member pattern hi-lock-interactive-patterns)
573 (push pattern hi-lock-interactive-patterns)
594 (defun hi-lock-set-file-patterns (patterns)
595 "Replace file patterns list with PATTERNS and refontify."
596 (when (or hi-lock-file-patterns patterns)
597 (font-lock-remove-keywords nil hi-lock-file-patterns)
598 (setq hi-lock-file-patterns patterns)
599 (font-lock-add-keywords nil hi-lock-file-patterns t)
602 (defun hi-lock-find-patterns ()
603 "Find patterns in current buffer for hi-lock."
606 (let ((all-patterns nil)
607 (target-regexp (concat "\\<" hi-lock-file-patterns-prefix ":")))
613 (+ (point) hi-lock-file-patterns-range) t)
618 (setq all-patterns (append (read (current-buffer)) all-patterns))
621 (when (and all-patterns
624 ((eq this-command 'hi-lock-find-patterns) t)
625 ((functionp hi-lock-file-patterns-policy)
626 (funcall hi-lock-file-patterns-policy all-patterns))
627 ((eq hi-lock-file-patterns-policy 'ask)
628 (y-or-n-p "Add patterns from this buffer to hi-lock? "))
630 (hi-lock-set-file-patterns all-patterns)
632 (message "Hi-lock added %d patterns." (length all-patterns)))))))
635 "Add hi-lock patterns to font-lock's."
638 (font-lock-add-keywords nil hi-lock-file-patterns t)
639 (font-lock-add-keywords nil hi-lock-interactive-patterns t))