aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-03-28 01:19:43 +0000
committerStefan Monnier2007-03-28 01:19:43 +0000
commit74cb3d2111ae0b87e7d7a20636a76a720a0771ed (patch)
tree12052d523873920d64e81b93cbad64b8f55b7065
parent4878f1de7c974282eb6f122eee6c73d45d454915 (diff)
downloademacs-74cb3d2111ae0b87e7d7a20636a76a720a0771ed.tar.gz
emacs-74cb3d2111ae0b87e7d7a20636a76a720a0771ed.zip
(vc-with-current-file-buffer): New macro.
(vc-arch-file-source-p): Use it to avoid infloop.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/vc-arch.el15
2 files changed, 19 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 53e7f65c968..979197be0c9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-03-28 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc-arch.el (vc-with-current-file-buffer): New macro.
4 (vc-arch-file-source-p): Use it to avoid infloop.
5
12007-03-28 David Hansen <david.hansen@gmx.net> (tiny change) 62007-03-28 David Hansen <david.hansen@gmx.net> (tiny change)
2 7
3 * emacs-lisp/lisp.el (lisp-complete-symbol): 8 * emacs-lisp/lisp.el (lisp-complete-symbol):
diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el
index 0f02db0ba96..488f9108d36 100644
--- a/lisp/vc-arch.el
+++ b/lisp/vc-arch.el
@@ -109,6 +109,19 @@
109 109
110(defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)") 110(defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)")
111 111
112(defmacro vc-with-current-file-buffer (file &rest body)
113 (declare (indent 2) (debug t))
114 `(let ((-kill-buf- nil)
115 (-file- ,file))
116 (with-current-buffer (or (find-buffer-visiting -file-)
117 (setq -kill-buf- (generate-new-buffer " temp")))
118 ;; Avoid find-file-literally since it can do many undesirable extra
119 ;; things (among which, call us back into an infinite loop).
120 (if -kill-buf- (insert-file-contents -file-))
121 (unwind-protect
122 (progn ,@body)
123 (if (buffer-live-p -kill-buf-) (kill-buffer -kill-buf-))))))
124
112(defun vc-arch-file-source-p (file) 125(defun vc-arch-file-source-p (file)
113 "Can return nil, `maybe' or a non-nil value. 126 "Can return nil, `maybe' or a non-nil value.
114Only the value `maybe' can be trusted :-(." 127Only the value `maybe' can be trusted :-(."
@@ -122,7 +135,7 @@ Only the value `maybe' can be trusted :-(."
122 (concat ".arch-ids/" (file-name-nondirectory file) ".id") 135 (concat ".arch-ids/" (file-name-nondirectory file) ".id")
123 (file-name-directory file))) 136 (file-name-directory file)))
124 ;; Check the presence of a tagline. 137 ;; Check the presence of a tagline.
125 (with-current-buffer (find-file-noselect file) 138 (vc-with-current-file-buffer file
126 (save-excursion 139 (save-excursion
127 (goto-char (point-max)) 140 (goto-char (point-max))
128 (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t) 141 (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t)