• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +defs:file +defs:regexp

11 ;; This file is part of GNU Emacs.
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
61 ;; You automatically save the completions you use to a file between
77 ;; When you load this file, completion will be on. I suggest you use the
87 ;; a completions database for a saved completions file
90 ;; the saved completion file.
102 ;; versions kept of the saved completions file is controlled by
103 ;; completions-file-versions-kept.
126 ;; m-x add-completions-from-lisp-file
127 ;; Parses all the definition names from a C or Lisp mode file and
148 ;; site's standard site-init file.
186 ;; Loads the completions file and sets up so that exiting emacs will
189 ;; save-completions-to-file &optional filename
190 ;; load-completions-from-file &optional filename
247 ;; - Fix broken completion merging (in save-completions-to-file)
261 ;; - Fixed bug with saving out .completion file the first time
276 ;; - added backup protection to save-completions-to-file (prevents
294 If nil, no new words are added to the database or saved to the init file."
304 (defcustom save-completions-file-name
307 ((file-readable-p olddef) olddef)
308 ((file-directory-p (convert-standard-filename "~/.emacs.d/"))
310 (expand-file-name "completions" "~/.emacs.d/")))
313 :type 'file
329 (defcustom completions-file-versions-kept kept-new-versions
330 "Number of versions to keep for the saved completions file."
383 Indicates that the old completion file has been read in.")
722 (defconst cmpl-source-init-file 1)
723 (defconst cmpl-source-file-parsing 2)
743 ;; We simply search backwards through the file looking for words which
758 ;; "Return t if the cdabbrev search has wrapped around the file.")
1438 (defvar cmpl-test-regexp "")
1439 ;; "The current regexp used by completion-search-next.
1465 cmpl-test-regexp (concat (regexp-quote string) "."))
1528 (and (not (eq 0 (string-match cmpl-test-regexp
1715 (defun add-completions-from-file (file)
1718 (setq file (expand-file-name file))
1719 (let* ((buffer (get-file-buffer file))
1723 (setq buffer (find-file-noselect file))))
1732 (let ((current-completion-source cmpl-source-file-parsing)
1735 (aref completion-add-count-vector cmpl-source-file-parsing)))
1747 (record-cmpl-parse-file
1749 (- (aref completion-add-count-vector cmpl-source-file-parsing)
1752 ;; Find file hook
1753 (defun completion-find-file-hook ()
1791 ;; We tried using forward-lines and explicit searches but the regexp technique
1794 (defconst *lisp-def-regexp*
1796 "A regexp that searches for Lisp definition form.")
1799 ;; (and (string-match *lisp-def-regexp* "\n(defun foo") (match-end 0)) -> 8
1800 ;; (and (string-match *lisp-def-regexp* "\n(si:def foo") (match-end 0)) -> 9
1801 ;; (and (string-match *lisp-def-regexp* "\n(def-bar foo")(match-end 0)) -> 10
1802 ;; (and (string-match *lisp-def-regexp* "\n(defun (foo") (match-end 0)) -> 9
1814 (re-search-forward *lisp-def-regexp*)
1822 ;; C file completion parsing
1860 (defconst *c-def-regexp*
1869 "A regexp that searches for a definition form.")
1871 ;(defconst *c-cont-regexp*
1873 ; "This regexp should be used in a looking-at to parse for lists of variables.")
1875 ;(defconst *c-struct-regexp*
1877 ; "This regexp should be used to test whether a symbol follows a structure definition.")
1879 ;(defun test-c-def-regexp (regexp string)
1880 ; (and (eq 0 (string-match regexp string)) (match-end 0))
1884 ;; (test-c-def-regexp *c-def-regexp* "\n#define foo") -> 10 (9)
1885 ;; (test-c-def-regexp *c-def-regexp* "\nfoo (x, y) {") -> 6 (6)
1886 ;; (test-c-def-regexp *c-def-regexp* "\nint foo (x, y)") -> 10 (5)
1887 ;; (test-c-def-regexp *c-def-regexp* "\n int foo (x, y)") -> nil
1888 ;; (test-c-def-regexp *c-cont-regexp* "oo, bar") -> 4
1889 ;; (test-c-def-regexp *c-cont-regexp* "oo, *bar") -> 5
1890 ;; (test-c-def-regexp *c-cont-regexp* "a [5][6], bar") -> 10
1891 ;; (test-c-def-regexp *c-cont-regexp* "oo(x,y)") -> nil
1892 ;; (test-c-def-regexp *c-cont-regexp* "a [6] ,\t bar") -> 9
1893 ;; (test-c-def-regexp *c-cont-regexp* "oo {trout =1} my_carp;") -> 14
1894 ;; (test-c-def-regexp *c-cont-regexp* "truct_p complex foon") -> nil
1912 (re-search-forward *c-def-regexp*)
1979 ;; The version of save-completions-to-file called at kill-emacs time.
1986 (save-completions-to-file))))
1994 (defconst saved-cmpl-file-header
1995 ";;; Completion Initialization file.
2000 ;; If it is t, the completion will never be pruned from the file.
2007 (defun save-completions-to-file (&optional filename)
2008 "Save completions in init file FILENAME.
2009 If file name is not specified, use `save-completions-file-name'."
2011 (setq filename (expand-file-name (or filename save-completions-file-name)))
2012 (if (file-writable-p filename)
2016 (message "Saving completions to file %s" filename)
2020 (kept-new-versions completions-file-versions-kept)
2029 (setq buffer-file-name filename)
2031 (if (not (verify-visited-file-modtime (current-buffer)))
2033 ;; file has changed on disk. Bring us up-to-date
2034 (message "Completion file has changed. Merging. . .")
2035 (load-completions-from-file filename t)
2036 (message "Merging finished. Saving completions to file %s" filename)))
2039 (clear-visited-file-modtime)
2042 (insert (format saved-cmpl-file-header completion-version))
2046 ;; Update num uses and maybe write completion to a file
2047 (cond ((or;; Write to file if
2062 ;; write to file
2069 (let ((file-exists-p (file-exists-p filename)))
2070 (if file-exists-p
2072 ;; If file exists . . .
2074 ;; (GNU leaves a 0 length file if it gets a disk full error!)
2077 ;; {If backup exists the primary file is probably messed up}
2078 (or (file-exists-p backup-filename)
2079 (rename-file filename backup-filename))
2082 (copy-file backup-filename filename t)))
2085 (if file-exists-p
2087 (delete-file backup-filename)))
2090 (message "Couldn't save completion file `%s'" filename)))
2101 ;; (save-completions-to-file)))
2105 (defun load-completions-from-file (&optional filename no-message-p)
2106 "Load a completion init file FILENAME.
2107 If file is not specified, then use `save-completions-file-name'."
2109 (setq filename (expand-file-name (or filename save-completions-file-name)))
2111 (backup-readable-p (file-readable-p backup-filename)))
2113 (if (file-readable-p filename)
2119 (setq buffer-file-name filename)
2121 (clear-visited-file-modtime)
2128 (current-completion-source cmpl-source-init-file)
2131 (aref completion-add-count-vector cmpl-source-file-parsing)))
2132 (total-in-file 0) (total-perm 0))
2133 ;; insert the file into a buffer
2135 (progn (insert-file-contents filename t)
2138 (file-error
2139 (message "File error trying to load completion file %s."
2149 (setq total-in-file (1+ total-in-file))
2182 (message "End of file while reading completions."))
2183 (end-of-file
2186 (message "Loading completions from file %s . . . Done."
2188 (message "End of file while reading completions."))))))
2192 total-in-file total-perm
2193 (- (aref completion-add-count-vector cmpl-source-init-file)
2198 "Load the default completions file.
2199 Also sets up so that exiting Emacs will automatically save the file."
2202 (load-completions-from-file)
2368 (dolist (x '((find-file-hook . completion-find-file-hook)
2451 (record-completion-file-loaded))