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

Lines Matching +defs:local +defs:file

12 ;; This file is part of GNU Emacs.
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
34 ;;; If a file *.`adp' exists in the ada-file directory, then it is
50 (require 'find-file)
110 "*Default command to be used to compile a single file.
112 the filename at the end. This is the same syntax as in the project file."
118 "*Default command to be used to compile a single file.
120 the filename at the end. This is the same syntax as in the project file."
131 This is the same syntax as in the project file."
134 (defcustom ada-prj-default-project-file ""
135 "*Name of the current project file.
136 Emacs will not try to use the search algorithm to find the project file if
137 this string is not empty. It is set whenever a project file is found."
138 :type '(file :must-match t) :group 'ada)
142 This has the same syntax as in the project file (with variable substitution)."
146 "*If nil, use default values when no project file was found.
147 Otherwise, ask the user for the name of the project file to use."
166 "Hook that is run when loading a project file.
168 the project file to load.
171 If the function can load the file with the given filename, it should create a
172 buffer that contains a conversion of the file to the standard format of the
175 file.")
179 (defvar ada-last-prj-file ""
180 "Name of the last project file entered by the user.")
182 (defconst ada-prj-file-extension ".adp"
198 (if (string-match "cmdproxy.exe" shell-file-name)
220 A project has the format: (project-file . project-plist)
226 project file, a (nil . default-properties) entry is created.")
237 (defmacro ada-file-of (identlist) (list 'aref identlist 3))
239 (defmacro ada-declare-file-of (identlist) (list 'aref identlist 5))
246 (defmacro ada-set-file (identlist file) (list 'aset identlist 3 file))
248 (defmacro ada-set-declare-file (identlist file) (list 'aset identlist 5 file))
252 (defsubst ada-get-ali-buffer (file)
253 "Read the ali file FILE into a new buffer, and return the buffer's name."
254 (find-file-noselect (ada-get-ali-file-name file)))
264 "Find the full path to the executable file EXEC-NAME.
266 (or (ada-find-file-in-dir exec-name exec-path)
267 (ada-find-file-in-dir (concat exec-name ".exe") exec-path)
330 file, minus extension but with directory, and ${full_current} is
338 (setq value (file-name-sans-extension (buffer-file-name))))
340 (setq value (buffer-file-name)))
366 (let ((file (buffer-file-name ada-buffer))
372 ;; Try hard to find a project file, even if the current
373 ;; buffer is not an Ada file or not associated with a file
374 (list 'filename (expand-file-name
376 (ada-prj-default-project-file
377 ada-prj-default-project-file)
378 (file (ada-prj-find-prj-file file t))
380 (message (concat "Not editing an Ada file,"
382 "file specified!"))
384 'build_dir (file-name-as-directory (expand-file-name "."))
387 'casing (if (listp ada-case-exception-file)
388 ada-case-exception-file
389 (list ada-case-exception-file))
395 'main (if file
396 (file-name-nondirectory
397 (file-name-sans-extension file))
399 'main_unit (if file
400 (file-name-nondirectory
401 (file-name-sans-extension file))
417 "Extract the value of FIELD from the current project file.
476 (let* ((file-name (ada-xref-current-project-file))
477 (project-plist (cdr (assoc file-name ada-xref-project-files))))
480 (setcdr (assoc file-name ada-xref-project-files) project-plist)))
487 ["Load..." ada-set-default-project-file t]
496 "Change the active project file."
498 (ada-parse-prj-file ,(car x))
499 (set 'ada-prj-default-project-file ,(car x))
502 (if (string= (file-name-extension name)
503 ada-prj-file-extension)
504 (file-name-sans-extension
505 (file-name-nondirectory name))
506 (file-name-nondirectory name))
510 (equal ada-prj-default-project-file
523 ;;-- Searching a file anywhere on the source path.
525 ;;-- The following functions provide support for finding a file anywhere
527 ;;-- They also provide file name completion in the minibuffer.
529 ;;-- Public subprograms: ada-find-file
533 (defun ada-do-file-completion (string predicate flag)
534 "Completion function when reading a file from the minibuffer.
536 defined in the project file."
542 (if (file-directory-p (car dirs))
543 (set 'list (append list (file-name-all-completions string (car dirs)))))
555 (defun ada-find-file (filename)
559 (list (completing-read "File: " 'ada-do-file-completion)))
560 (let ((file (ada-find-src-file-in-dir filename)))
561 (if file
562 (find-file file)
568 (defun ada-require-project-file ()
572 (ada-reread-prj-file)))
574 (defun ada-xref-current-project-file (&optional no-user-question)
575 "Return the current project file name; never nil unless NO-USER-QUESTION.
576 If NO-USER-QUESTION, don't prompt user for file. Call
577 `ada-require-project-file' first if a project must exist."
578 (if (not (string= "" ada-prj-default-project-file))
579 ada-prj-default-project-file
580 (ada-prj-find-prj-file nil no-user-question)))
584 If NO-USER-QUESTION, don't prompt user for file. Call
585 `ada-require-project-file' first if a project must exist."
586 (let* ((file-name (ada-xref-current-project-file no-user-question)))
587 (assoc file-name ada-xref-project-files)))
590 "Display current project file name in message buffer."
592 (message (ada-xref-current-project-file)))
611 (find-file (car (cdr pos)))
614 (defun ada-convert-file-name (name)
620 (defun ada-set-default-project-file (name &optional keep-existing)
621 "Set the file whose name is NAME as the default project file.
622 If KEEP-EXISTING is true and a project file has already been loaded, nothing
624 a project file unless the user has already loaded one."
625 (interactive "fProject file:")
627 (not ada-prj-default-project-file)
628 (equal ada-prj-default-project-file ""))
630 (setq ada-prj-default-project-file name)
631 (ada-reread-prj-file name))))
633 ;; ------ Handling the project file -----------------------------
635 (defun ada-prj-find-prj-file (&optional file no-user-question)
636 "Find the project file associated with FILE (or the current buffer if nil).
637 If the buffer is not in Ada mode, or not associated with a file,
638 return `ada-prj-default-project-file'. Otherwise, search for a file with
639 the same base name as the Ada file, but extension given by
640 `ada-prj-file-extension' (default .adp). If not found, search for *.adp
648 (not (buffer-file-name)))
651 ;; with a file (for instance an emerge buffer)
653 (if (and ada-prj-default-project-file
654 (not (string= ada-prj-default-project-file "")))
655 (setq selected ada-prj-default-project-file)
660 (let* ((current-file (or file (buffer-file-name)))
662 (file-name-sans-extension current-file)
663 ada-prj-file-extension))
664 (dir (file-name-directory current-file))
672 ada-prj-file-extension) "$")))
677 ((file-exists-p first-choice)
682 ;; Exactly one project file was found in the current directory
689 (princ "There are more than one possible project file.\n")
691 (princ " no. file name \n")
712 ;; No project file in the current directory; ask user
714 (setq ada-last-prj-file
715 (read-file-name
716 (concat "project file [" ada-last-prj-file "]:")
717 nil ada-last-prj-file))
718 (unless (string= ada-last-prj-file "")
719 (set 'selected ada-last-prj-file))))
726 (defun ada-parse-prj-file (prj-file)
729 (if prj-file
733 (setq prj-file (expand-file-name prj-file))
735 ;; Set the project file as the active one.
736 (setq ada-prj-default-project-file prj-file)
741 ;; Do not use find-file below, since we don't want to show this
742 ;; buffer. If the file is open through speedbar, we can't use
743 ;; find-file anyway, since the speedbar frame is special and does not
744 ;; allow the selection of a file in it.
746 (if (file-exists-p prj-file)
749 'ada-load-project-hook prj-file)))
751 (setq buffer (find-file-noselect prj-file nil)))
757 ;; Now overrides these values with the project file
765 (file-name-as-directory (match-string 2))))
768 (file-name-as-directory (match-string 2))))
774 (file-name-as-directory (match-string 2)))))
788 ;; any other field in the file is just copied
815 ;; Else the file wasn't readable (probably the default project).
836 ;; Delete the default project file from the list, if it is there.
842 ;; Memorize the newly read project file
843 (if (assoc prj-file ada-xref-project-files)
844 (setcdr (assoc prj-file ada-xref-project-files) project)
845 (add-to-list 'ada-xref-project-files (cons prj-file project)))
851 ;; Set the casing exceptions file list
854 (setq ada-case-exception-file (reverse casing))
857 ;; Add the directories to the search path for ff-find-other-file
860 (append (mapcar 'directory-file-name compilation-search-path)
866 ;; No prj file ? => Setup default values
868 ;; current directory, and only then in the current file's directory. This
869 ;; current file is assumed at this point to be in the common source
875 (defun ada-find-references (&optional pos arg local-only)
879 If LOCAL-ONLY is t, only the declarations in the current file are returned."
881 (ada-require-project-file)
884 (alifile (ada-get-ali-file-name (ada-file-of identlist)))
887 (set-buffer (get-file-buffer (ada-file-of identlist)))
889 ;; if the file is more recent than the executable
891 (file-newer-than-file-p (ada-file-of identlist) alifile))
893 (ada-file-of identlist)
894 nil nil local-only arg)
896 (ada-file-of identlist)
898 (ada-column-of identlist) local-only arg)))
901 (defun ada-find-local-references (&optional pos arg)
909 (entity &optional file line column local-only append)
917 (ada-require-project-file)
931 (if file (concat ":" (file-name-nondirectory file)))
934 (if local-only (concat " " (file-name-nondirectory file)))
938 ;; If a project file is defined, use it
939 (if (and ada-prj-default-project-file
940 (not (string= ada-prj-default-project-file "")))
941 (if (string-equal (file-name-extension ada-prj-default-project-file)
943 (setq command (concat command " -P" ada-prj-default-project-file))
944 (setq command (concat command " -p" ada-prj-default-project-file))))
957 (local-unset-key [menu-bar compilation-menu])
967 (defalias 'ada-change-prj (symbol-function 'ada-set-default-project-file))
973 (ada-require-project-file)
975 ;; Initialize function-local variables and jump to the .ali buffer
985 ;; Open the .ali file
986 (set-buffer (ada-get-ali-buffer (buffer-file-name)))
1039 (ada-require-project-file)
1041 (ada-xref-push-pos (buffer-file-name) pos)
1043 ;; First try the standard algorithm by looking into the .ali file, but if
1044 ;; that file was too old or even did not exist, try to look in the whole
1050 (error-file-not-found
1055 (let ((ali-file (ada-get-ali-file-name (ada-file-of identlist))))
1057 ;; If the ALI file was up-to-date, then we probably have a predefined
1059 (if (and (file-exists-p ali-file)
1060 (file-newer-than-file-p ali-file (ada-file-of identlist)))
1063 ;; Else, look in every ALI file, except if the user doesn't want that
1088 (mapcar (lambda (x) (expand-file-name x root-dir)) dir-list))
1095 project file."
1105 (mapconcat (lambda(x) (expand-file-name x build-dir))
1111 (mapconcat (lambda(x) (expand-file-name x build-dir))
1118 "Compile the application, using the command found in the project file.
1121 (ada-require-project-file)
1128 ;; If no project file was found, ask the user
1142 (if (not (string-match ".exe" shell-file-name))
1150 (ada-require-project-file)
1151 (let* ((file (buffer-file-name (current-buffer)))
1153 (if (not file)
1154 (error "No file for current buffer")
1157 (if file
1158 (file-name-nondirectory
1159 (file-name-sans-extension file))
1166 "Recompile the current file.
1168 PRJ-FIELD is the name of the field to use in the project file to get the
1171 (ada-require-project-file)
1186 ;; If no project file was found, ask the user
1193 "Check the current file for syntax errors.
1202 (ada-require-project-file)
1212 (set 'command (list (file-name-sans-extension (buffer-name)))))
1229 (start-process "run" (current-buffer) shell-file-name
1235 (set (make-local-variable 'scroll-step) 0)
1236 (set (make-local-variable 'scroll-conservatively) 0)
1248 EXECUTABLE-NAME, if non-nil, is debugged instead of the file specified in the
1249 project file."
1251 (ada-require-project-file)
1260 ;; If the command was not given in the project file, start a bare gdb
1265 (file-name-sans-extension (buffer-file-name))))))
1295 (fset 'gud-gdb-massage-args (lambda (file args) args))
1353 (defun ada-reread-prj-file (&optional filename)
1357 (ada-parse-prj-file filename)
1358 (ada-parse-prj-file (ada-prj-find-prj-file)))
1367 (defun ada-xref-current (file &optional ali-file-name)
1370 This function returns the name of the file that was recompiled to generate
1371 the cross-reference information. Note that the ali file can then be deduced
1372 by replacing the file extension with `.ali'."
1374 (if (and ali-file-name
1375 (get-file-buffer ali-file-name))
1376 (kill-buffer (get-file-buffer ali-file-name)))
1378 (let* ((name (ada-convert-file-name file))
1388 (find-file body-name))
1391 ;; process, or the ALI file would still not be available.
1407 (defun ada-find-file-in-dir (file dir-list)
1411 (set 'found (concat (file-name-as-directory (car dir-list))
1412 (file-name-nondirectory file)))
1414 (unless (file-exists-p found)
1419 (defun ada-find-ali-file-in-dir (file)
1420 "Find the ali file FILE, searching obj_dir for the current project.
1423 (ada-find-file-in-dir file (ada-xref-get-obj-dir-field)))
1425 (defun ada-find-src-file-in-dir (file)
1426 "Find the source file FILE, searching src_dir for the current project.
1429 (ada-find-file-in-dir file (ada-xref-get-src-dir-field)))
1431 (defun ada-get-ali-file-name (file)
1432 "Create the ali file name for the ada-file FILE.
1433 The file is searched for in every directory shown in the obj_dir lines of
1434 the project file."
1437 ;; file names (i.e. not .adb or .ads)
1439 ;; 1- replace the extension of the current file with .ali,
1440 ;; and look for this file
1441 ;; 2- If this file is found:
1443 ;; .ali file for a spec file. If we are, go to step 3.
1444 ;; 3- If the file is not found or step 2 failed:
1445 ;; find the name of the "other file", ie the body, and look
1446 ;; for its associated .ali file by subtituing the extension
1449 ;; 4- If no ali file was found, we try to modify the file name by removing
1451 ;; ali file for the parent unit. If we found an ali file, we check that
1457 (set-buffer (get-file-buffer file))
1458 (let ((short-ali-file-name
1459 (concat (file-name-sans-extension (file-name-nondirectory file))
1461 ali-file-name
1464 ;; If we have a non-standard file name, and this is a spec, we first
1465 ;; look for the .ali file of the body, since this is the one that
1467 ;; we can with the .ali file for the spec...
1469 (if (not (string= (file-name-extension file) "ads"))
1473 file)
1478 (set 'ali-file-name
1479 (ada-find-ali-file-in-dir
1480 (concat (file-name-sans-extension
1481 (file-name-nondirectory
1482 (ada-other-file-name)))
1486 (setq ali-file-name
1487 (or ali-file-name
1489 ;; Else we take the .ali file associated with the unit
1490 (ada-find-ali-file-in-dir short-ali-file-name)
1493 ;; else we did not find the .ali file Second chance: in case
1495 ;; file_s.ada and file_b.ada), try to go to the other file
1496 ;; and look for its ali file
1497 (ada-find-ali-file-in-dir
1498 (concat (file-name-sans-extension
1499 (file-name-nondirectory (ada-other-file-name)))
1503 ;; If we still don't have an ali file, try to get the one
1505 (let ((parent-name (file-name-sans-extension
1506 (file-name-nondirectory file))))
1508 (while (and (not ali-file-name)
1512 (set 'ali-file-name (ada-find-ali-file-in-dir
1515 ali-file-name)))
1517 ;; If still not found, try to recompile the file
1518 (if (not ali-file-name)
1524 (setq ali-file-name
1525 (concat (file-name-sans-extension (ada-xref-current file))
1528 (error "`.ali' file not found; recompile your source file"))
1531 ;; same if the .ali file is too old and we must recompile it
1532 (if (and (file-newer-than-file-p file ali-file-name)
1534 (ada-xref-current file ali-file-name)))
1536 ;; Always return the correct absolute file name
1537 (expand-file-name ali-file-name))
1540 (defun ada-get-ada-file-name (file original-file)
1541 "Create the complete file name (+directory) for FILE.
1542 The original file (where the user was) is ORIGINAL-FILE.
1543 Search in project file for possible paths."
1547 ;; If the buffer for original-file, use it to get the values from the
1548 ;; project file, otherwise load the file and its project file
1549 (let ((buffer (get-file-buffer original-file)))
1552 (find-file original-file)))
1555 ;; return the absolute file name
1556 (let ((filename (ada-find-src-file-in-dir file)))
1558 (expand-file-name filename)
1559 (signal 'error-file-not-found (file-name-nondirectory file)))
1562 (defun ada-find-file-number-in-ali (file)
1563 "Return the file number for FILE in the associated ali file."
1564 (set-buffer (ada-get-ali-buffer file))
1569 (re-search-forward (concat "^D " (file-name-nondirectory file)))
1575 macros `ada-name-of', `ada-line-of', `ada-column-of', `ada-file-of',..."
1625 (ada-set-file identlist (buffer-file-name))
1630 "Complete IDENTLIST with definition file and places where it is referenced.
1631 Information is extracted from the ali file."
1633 (let ((ali-buffer (ada-get-ali-buffer (ada-file-of identlist)))
1641 ;; the "^X ..." line for the current file, and before the next "^X" line
1644 (concat "^X [0-9]+ " (file-name-nondirectory (ada-file-of identlist)))
1662 ;; Since we alread know the number of the file, search for a direct
1668 (number-to-string (ada-find-file-number-in-ali
1669 (ada-file-of identlist))))
1691 ;; or the source file has been modified since the ali file was
1710 ;; Still no success ! The ali file must be too old, and we need to
1726 ;; Now that we have found a suitable line in the .ali file, get the
1742 ;; If we can find the file
1744 (ada-set-declare-file
1746 (ada-get-ada-file-name (match-string 1)
1747 (ada-file-of identlist)))
1749 ;; Else clean up the ali file
1750 (error-file-not-found
1763 This function is only called when the file was not up-to-date, so we need
1792 ;; construct a list with the file names and the positions within
1808 " recorded in .ali file")))
1821 (princ " no. in file at line col\n")
1827 (ada-get-ada-file-name
1829 (ada-file-of identlist))
1853 "Look in the .ali file for the definition of the identifier in IDENTLIST.
1861 file line col)
1872 (ada-declare-file-of identlist))))
1879 ;; it there was a file number in the same line
1880 ;; Make sure we correctly handle the case where the first file reference
1886 (let ((file-number (match-string 1 ali-line)))
1889 (string-to-number file-number))
1890 (set 'file (match-string 1))
1892 ;; Else get the nearest file
1893 (set 'file (ada-declare-file-of identlist)))
1895 (set 'locations (append locations (list (list line col file)))))
1906 file (nth 2 (car locations)))
1911 (string= (file-name-nondirectory (nth 2 (car locations)))
1912 (file-name-nondirectory (ada-file-of identlist))))
1916 file (nth 2 locations)
1920 ;; Find the file in the source path
1921 (set 'file (ada-get-ada-file-name file (ada-file-of identlist)))
1927 (ada-xref-change-buffer file
1937 .ali file has failed, either because that file was too old or even did not
1951 file)
1956 ;; commands instead of one in case there is no .ali file in one
1966 (shell-quote-argument (file-name-as-directory (car dirs)))
1982 (set 'file (list (match-string 1) line column))
1986 (unless (member file list)
1987 (set 'list (append list (list file))))))))
1998 (error "No cross-reference found, please recompile your file"))
2002 (set 'file (ada-find-src-file-in-dir (caar list)))
2003 (if file
2004 (ada-xref-change-buffer file
2020 (princ " no. in file at line col\n")
2044 (set 'file (ada-find-src-file-in-dir (car (nth choice list))))
2045 (if file
2046 (ada-xref-change-buffer file
2051 (signal 'error-file-not-found (car (nth choice list))))
2056 (file line column identlist &optional other-frame)
2060 If OTHER-FRAME is non-nil, creates a new frame to show the file."
2067 (find-file-other-frame file)
2068 (set 'declaration-buffer (find-file-noselect file))
2072 (find-file file)
2080 ;; If we are not on the identifier, the ali file was not up-to-date.
2089 "Search for NAME nearest to the position recorded in the Xref file.
2097 ;; loop - look for all declarations of name in this file
2132 ;; Find the parent library file of the current file
2134 "Go to the parent library file."
2136 (ada-require-project-file)
2138 (let ((buffer (ada-get-ali-buffer (buffer-file-name)))
2154 ;; look for the file name for the parent unit specification
2164 (setq ali-name (ada-find-ali-file-in-dir ali-name))
2167 ;; Tries to open the new ali file to find the spec file
2170 (find-file ali-name)
2180 (find-file body-name)
2215 This function typically is to be hooked into `ff-file-created-hook'."
2217 (ada-require-project-file)
2222 ;; function from ff-file-created-hook), then kill this temporary buffer
2229 ;; if for instance the user was asked for a project file)
2231 (unless (buffer-file-name (car (buffer-list)))
2236 (filename (buffer-file-name (car (buffer-list))))
2237 (output (concat (file-name-sans-extension filename) ".adb"))
2248 ;; call gnatstub to create the body file
2249 (call-process shell-file-name nil buffer nil "-c" gnatstub-cmd)
2263 (if (file-exists-p output)
2265 (find-file output)
2276 `find-file'."
2277 (remove-hook 'ff-file-created-hook 'ada-make-body) ; from global hook
2278 (remove-hook 'ff-file-created-hook 'ada-make-body t) ; from local hook
2279 (add-hook 'ff-file-created-hook 'ada-make-body-gnatstub nil t)
2281 ;; Completion for file names in the mini buffer should ignore .ali files
2293 (put 'error-file-not-found
2295 '(error ada-mode-errors error-file-not-found))
2296 (put 'error-file-not-found
2298 "File not found in src-dir (check project file): ")
2305 (append (mapcar 'directory-file-name ada-xref-runtime-library-specs-path)