aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-09-12 05:01:06 +0000
committerRichard M. Stallman2005-09-12 05:01:06 +0000
commit7957baeaafcefb61f337aa6f2d05c8fa4e62ab2c (patch)
tree2e926d6a934109754cad9ea5780f31ac2a471a01
parent7318a7a31ee749cc2c5913a50aade124fcaaabbf (diff)
downloademacs-7957baeaafcefb61f337aa6f2d05c8fa4e62ab2c.tar.gz
emacs-7957baeaafcefb61f337aa6f2d05c8fa4e62ab2c.zip
Don't decide a file's directory
until the user actually tries to go there. (compilation-next-error-function): Pass compilation-find-file the directory from the file-struct. (compilation-internal-error-properties): Separate local FILE-STRUCT from FILE. Doc the args better. Rename arg FMT to FMTS. (compilation-find-file): Arg DIR renamed to DIRECTORY. Expand it, and if nil, use default-directory. (compilation-get-file-structure): Don't mix specified directory with default directory. Put specified directory into file-struct. Don't make the file name absolute. (compilation-error-regexp-alist): Doc fix. (compile-command): Add autoload. (compilation-disable-input): Add autoload.
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/progmodes/compile.el92
2 files changed, 68 insertions, 42 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 52eb22cb318..dd05402e3ac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,21 @@
12005-09-12 Richard M. Stallman <rms@gnu.org>
2
3 * progmodes/compile.el: Don't decide a file's directory
4 until the user actually tries to go there.
5 (compilation-next-error-function):
6 Pass compilation-find-file the directory from the file-struct.
7 (compilation-internal-error-properties): Separate local FILE-STRUCT
8 from FILE. Doc the args better. Rename arg FMT to FMTS.
9 (compilation-find-file): Arg DIR renamed to DIRECTORY.
10 Expand it, and if nil, use default-directory.
11 (compilation-get-file-structure): Don't mix specified directory
12 with default directory. Put specified directory into
13 file-struct. Don't make the file name absolute.
14
15 * progmodes/compile.el (compilation-error-regexp-alist): Doc fix.
16 (compile-command): Add autoload.
17 (compilation-disable-input): Add autoload.
18
12005-09-11 Stephen Gildea <gildea@stop.mail-abuse.org> 192005-09-11 Stephen Gildea <gildea@stop.mail-abuse.org>
2 20
3 * time-stamp.el: Mention variable `time-stamp-pattern' in doc 21 * time-stamp.el: Mention variable `time-stamp-pattern' in doc
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index f0836cbf2b0..f29051ab0b0 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -307,7 +307,7 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
307(defcustom compilation-error-regexp-alist 307(defcustom compilation-error-regexp-alist
308 (mapcar 'car compilation-error-regexp-alist-alist) 308 (mapcar 'car compilation-error-regexp-alist-alist)
309 "Alist that specifies how to match errors in compiler output. 309 "Alist that specifies how to match errors in compiler output.
310Note that on Unix everything is a valid filename, so these 310On GNU and Unix, any string is a valid filename, so these
311matchers must make some common sense assumptions, which catch 311matchers must make some common sense assumptions, which catch
312normal cases. A shorter list will be lighter on resource usage. 312normal cases. A shorter list will be lighter on resource usage.
313 313
@@ -436,6 +436,7 @@ nil as an element means to try the default directory."
436 (string :tag "Directory"))) 436 (string :tag "Directory")))
437 :group 'compilation) 437 :group 'compilation)
438 438
439;;;###autoload
439(defcustom compile-command "make -k " 440(defcustom compile-command "make -k "
440 "*Last shell command used to do a compilation; default for next compilation. 441 "*Last shell command used to do a compilation; default for next compilation.
441 442
@@ -452,6 +453,7 @@ You might also use mode hooks to specify it in certain modes, like this:
452 :type 'string 453 :type 'string
453 :group 'compilation) 454 :group 'compilation)
454 455
456;;;###autoload
455(defcustom compilation-disable-input nil 457(defcustom compilation-disable-input nil
456 "*If non-nil, send end-of-file as compilation process input. 458 "*If non-nil, send end-of-file as compilation process input.
457This only affects platforms that support asynchronous processes (see 459This only affects platforms that support asynchronous processes (see
@@ -664,24 +666,26 @@ just char-counts."
664 (move-to-column col) 666 (move-to-column col)
665 (goto-char (min (+ (line-beginning-position) col) (line-end-position))))) 667 (goto-char (min (+ (line-beginning-position) col) (line-end-position)))))
666 668
667(defun compilation-internal-error-properties (file line end-line col end-col type fmt) 669(defun compilation-internal-error-properties (file line end-line col end-col type fmts)
668 "Get the meta-info that will be added as text-properties. 670 "Get the meta-info that will be added as text-properties.
669LINE, END-LINE, COL, END-COL are integers or nil. 671LINE, END-LINE, COL, END-COL are integers or nil.
670TYPE can be 0, 1, or 2. 672TYPE can be 0, 1, or 2, meaning error, warning, or just info.
671FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME) or nil." 673FILE should be (FILENAME) or (RELATIVE-FILENAME . DIRNAME) or nil.
674FMTS is a list of format specs for transforming the file name.
675 (See `compilation-error-regexp-alist'.)"
672 (unless file (setq file '("*unknown*"))) 676 (unless file (setq file '("*unknown*")))
673 (setq file (compilation-get-file-structure file fmt)) 677 (let* ((file-struct (compilation-get-file-structure file fmts))
674 ;; Get first already existing marker (if any has one, all have one). 678 ;; Get first already existing marker (if any has one, all have one).
675 ;; Do this first, as the compilation-assq`s may create new nodes. 679 ;; Do this first, as the compilation-assq`s may create new nodes.
676 (let* ((marker-line (car (cddr file))) ; a line structure 680 (marker-line (car (cddr file-struct))) ; a line structure
677 (marker (nth 3 (cadr marker-line))) ; its marker 681 (marker (nth 3 (cadr marker-line))) ; its marker
678 (compilation-error-screen-columns compilation-error-screen-columns) 682 (compilation-error-screen-columns compilation-error-screen-columns)
679 end-marker loc end-loc) 683 end-marker loc end-loc)
680 (if (not (and marker (marker-buffer marker))) 684 (if (not (and marker (marker-buffer marker)))
681 (setq marker) ; no valid marker for this file 685 (setq marker nil) ; no valid marker for this file
682 (setq loc (or line 1)) ; normalize no linenumber to line 1 686 (setq loc (or line 1)) ; normalize no linenumber to line 1
683 (catch 'marker ; find nearest loc, at least one exists 687 (catch 'marker ; find nearest loc, at least one exists
684 (dolist (x (nthcdr 3 file)) ; loop over remaining lines 688 (dolist (x (nthcdr 3 file-struct)) ; loop over remaining lines
685 (if (> (car x) loc) ; still bigger 689 (if (> (car x) loc) ; still bigger
686 (setq marker-line x) 690 (setq marker-line x)
687 (if (> (- (or (car marker-line) 1) loc) 691 (if (> (- (or (car marker-line) 1) loc)
@@ -710,17 +714,18 @@ FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME) or nil."
710 (forward-to-indentation 0)) 714 (forward-to-indentation 0))
711 (setq marker (list (point-marker)))))) 715 (setq marker (list (point-marker))))))
712 716
713 (setq loc (compilation-assq line (cdr file))) 717 (setq loc (compilation-assq line (cdr file-struct)))
714 (if end-line 718 (if end-line
715 (setq end-loc (compilation-assq end-line (cdr file)) 719 (setq end-loc (compilation-assq end-line (cdr file-struct))
716 end-loc (compilation-assq end-col end-loc)) 720 end-loc (compilation-assq end-col end-loc))
717 (if end-col ; use same line element 721 (if end-col ; use same line element
718 (setq end-loc (compilation-assq end-col loc)))) 722 (setq end-loc (compilation-assq end-col loc))))
719 (setq loc (compilation-assq col loc)) 723 (setq loc (compilation-assq col loc))
720 ;; If they are new, make the loc(s) reference the file they point to. 724 ;; If they are new, make the loc(s) reference the file they point to.
721 (or (cdr loc) (setcdr loc `(,line ,file ,@marker))) 725 (or (cdr loc) (setcdr loc `(,line ,file-struct ,@marker)))
722 (if end-loc 726 (if end-loc
723 (or (cdr end-loc) (setcdr end-loc `(,(or end-line line) ,file ,@end-marker)))) 727 (or (cdr end-loc)
728 (setcdr end-loc `(,(or end-line line) ,file-struct ,@end-marker))))
724 729
725 ;; Must start with face 730 ;; Must start with face
726 `(face ,compilation-message-face 731 `(face ,compilation-message-face
@@ -1570,8 +1575,7 @@ This is the value of `next-error-function' in Compilation buffers."
1570 ;; markers for that file. 1575 ;; markers for that file.
1571 (unless (and (nth 3 loc) (marker-buffer (nth 3 loc))) 1576 (unless (and (nth 3 loc) (marker-buffer (nth 3 loc)))
1572 (with-current-buffer (compilation-find-file marker (caar (nth 2 loc)) 1577 (with-current-buffer (compilation-find-file marker (caar (nth 2 loc))
1573 (or (cdar (nth 2 loc)) 1578 (cadr (car (nth 2 loc))))
1574 default-directory))
1575 (save-restriction 1579 (save-restriction
1576 (widen) 1580 (widen)
1577 (goto-char (point-min)) 1581 (goto-char (point-min))
@@ -1734,16 +1738,21 @@ and overlay is highlighted between MK and END-MK."
1734 (copy-marker (line-beginning-position)))))) 1738 (copy-marker (line-beginning-position))))))
1735 1739
1736 1740
1737(defun compilation-find-file (marker filename dir &rest formats) 1741(defun compilation-find-file (marker filename directory &rest formats)
1738 "Find a buffer for file FILENAME. 1742 "Find a buffer for file FILENAME.
1739Search the directories in `compilation-search-path'. 1743Search the directories in `compilation-search-path'.
1740A nil in `compilation-search-path' means to try the 1744A nil in `compilation-search-path' means to try the
1741current directory, which is passed in DIR. 1745\"current\" directory, which is passed in DIRECTORY.
1746If DIRECTORY. is relative, it is combined with `default-directory'.
1747If DIRECTORY. is nil, that means use `default-directory'.
1742If FILENAME is not found at all, ask the user where to find it. 1748If FILENAME is not found at all, ask the user where to find it.
1743Pop up the buffer containing MARKER and scroll to MARKER if we ask the user." 1749Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1744 (or formats (setq formats '("%s"))) 1750 (or formats (setq formats '("%s")))
1745 (save-excursion 1751 (save-excursion
1746 (let ((dirs compilation-search-path) 1752 (let ((dirs compilation-search-path)
1753 (spec-dir (if directory
1754 (expand-file-name directory)
1755 default-directory))
1747 buffer thisdir fmts name) 1756 buffer thisdir fmts name)
1748 (if (file-name-absolute-p filename) 1757 (if (file-name-absolute-p filename)
1749 ;; The file name is absolute. Use its explicit directory as 1758 ;; The file name is absolute. Use its explicit directory as
@@ -1753,7 +1762,7 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1753 filename (file-name-nondirectory filename))) 1762 filename (file-name-nondirectory filename)))
1754 ;; Now search the path. 1763 ;; Now search the path.
1755 (while (and dirs (null buffer)) 1764 (while (and dirs (null buffer))
1756 (setq thisdir (or (car dirs) dir) 1765 (setq thisdir (or (car dirs) spec-dir)
1757 fmts formats) 1766 fmts formats)
1758 ;; For each directory, try each format string. 1767 ;; For each directory, try each format string.
1759 (while (and fmts (null buffer)) 1768 (while (and fmts (null buffer))
@@ -1771,7 +1780,7 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1771 (read-file-name 1780 (read-file-name
1772 (format "Find this %s in: (default %s) " 1781 (format "Find this %s in: (default %s) "
1773 compilation-error filename) 1782 compilation-error filename)
1774 dir filename t)))) 1783 spec-dir filename t))))
1775 (if (file-directory-p name) 1784 (if (file-directory-p name)
1776 (setq name (expand-file-name filename name))) 1785 (setq name (expand-file-name filename name)))
1777 (setq buffer (and (file-exists-p name) 1786 (setq buffer (and (file-exists-p name)
@@ -1785,26 +1794,32 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1785 1794
1786(defun compilation-get-file-structure (file &optional fmt) 1795(defun compilation-get-file-structure (file &optional fmt)
1787 "Retrieve FILE's file-structure or create a new one. 1796 "Retrieve FILE's file-structure or create a new one.
1788FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME)." 1797FILE should be (FILENAME) or (RELATIVE-FILENAME . DIRNAME).
1798In the former case, FILENAME may be relative or absolute.
1789 1799
1800The file-structure looks like this:
1801 (list (list FILENAME [DIR-FROM-PREV-MSG]) FMT LINE-STRUCT...)
1802"
1790 (or (gethash file compilation-locs) 1803 (or (gethash file compilation-locs)
1791 ;; File was not previously encountered, at least not in the form passed. 1804 ;; File was not previously encountered, at least not in the form passed.
1792 ;; Let's normalize it and look again. 1805 ;; Let's normalize it and look again.
1793 (let ((filename (car file)) 1806 (let ((filename (car file))
1794 (default-directory (if (cdr file) 1807 ;; Get the specified directory from FILE.
1795 (file-truename (cdr file)) 1808 (spec-directory (if (cdr file)
1796 default-directory))) 1809 (file-truename (cdr file)))))
1797 1810
1798 ;; Check for a comint-file-name-prefix and prepend it if appropriate. 1811 ;; Check for a comint-file-name-prefix and prepend it if appropriate.
1799 ;; (This is very useful for compilation-minor-mode in an rlogin-mode 1812 ;; (This is very useful for compilation-minor-mode in an rlogin-mode
1800 ;; buffer.) 1813 ;; buffer.)
1801 (if (boundp 'comint-file-name-prefix) 1814 (when (and (boundp 'comint-file-name-prefix)
1802 (if (file-name-absolute-p filename) 1815 (not (equal comint-file-name-prefix "")))
1803 (setq filename 1816 (if (file-name-absolute-p filename)
1804 (concat (with-no-warnings comint-file-name-prefix) filename)) 1817 (setq filename
1805 (setq default-directory 1818 (concat comint-file-name-prefix filename))
1806 (file-truename 1819 (if spec-directory
1807 (concat (with-no-warnings comint-file-name-prefix) default-directory))))) 1820 (setq spec-directory
1821 (file-truename
1822 (concat comint-file-name-prefix spec-directory))))))
1808 1823
1809 ;; If compilation-parse-errors-filename-function is 1824 ;; If compilation-parse-errors-filename-function is
1810 ;; defined, use it to process the filename. 1825 ;; defined, use it to process the filename.
@@ -1820,20 +1835,13 @@ FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME)."
1820 ;; name and fix them. 1835 ;; name and fix them.
1821 (setq filename (command-line-normalize-file-name filename)) 1836 (setq filename (command-line-normalize-file-name filename))
1822 1837
1823 ;; Now eliminate any "..", because find-file would get them wrong.
1824 ;; Make relative and absolute filenames, with or without links, the
1825 ;; same.
1826 (setq filename
1827 (list (abbreviate-file-name
1828 (file-truename (if (cdr file)
1829 (expand-file-name filename)
1830 filename)))))
1831
1832 ;; Store it for the possibly unnormalized name 1838 ;; Store it for the possibly unnormalized name
1833 (puthash file 1839 (puthash file
1834 ;; Retrieve or create file-structure for normalized name 1840 ;; Retrieve or create file-structure for normalized name
1835 (or (gethash filename compilation-locs) 1841 (or (gethash (list filename) compilation-locs)
1836 (puthash filename (list filename fmt) compilation-locs)) 1842 (puthash (list filename)
1843 (list (list filename spec-directory) fmt)
1844 compilation-locs))
1837 compilation-locs)))) 1845 compilation-locs))))
1838 1846
1839(add-to-list 'debug-ignored-errors "^No more [-a-z ]+s yet$") 1847(add-to-list 'debug-ignored-errors "^No more [-a-z ]+s yet$")