summaryrefslogtreecommitdiffstats
path: root/lib/quilt.el
diff options
context:
space:
mode:
authorSatoru Takeuchi <satoru.takeuchi@gmail.com>2012-03-10 18:36:52 +0900
committerSatoru Takeuchi <satoru.takeuchi@gmail.com>2012-03-10 18:36:52 +0900
commit912879381e7f96a735fe0542318a40f8ac9283cb (patch)
treec641f3f775dceca123cc428300443e53b8a826f7 /lib/quilt.el
parent9d4e0df85f1a72b2738b0c6de2e8c9b00299fadd (diff)
downloadquilt-912879381e7f96a735fe0542318a40f8ac9283cb.tar.gz
quilt-el: fix polluting namespace by nested function.
Diffstat (limited to 'lib/quilt.el')
-rw-r--r--lib/quilt.el62
1 files changed, 29 insertions, 33 deletions
diff --git a/lib/quilt.el b/lib/quilt.el
index a907206..e1e8c12 100644
--- a/lib/quilt.el
+++ b/lib/quilt.el
@@ -118,28 +118,31 @@
(substring (quilt-cmd-to-string "top") 0 -1))))
(defun quilt-complete-list (p l)
- (defun to-alist (list n)
- (if list
- (cons (cons (car list) n)
- (to-alist (cdr list) (+ 1 n)))
- nil))
- (completing-read p (to-alist l 0) nil t))
+ ; First turn the list into an alist using indices as keys.
+ ; This modifies the list passed as an argument.
+ (let ((list l)
+ (n 0))
+ (while list
+ (setcar list (cons (car list) n))
+ (setq list (cdr list))
+ (setq n (1+ n))))
+ (completing-read p l nil t))
(defun quilt-editable (f)
(let ((qd (quilt-dir))
- (fn (quilt-drop-dir f)))
- (defun editable (file dirs)
- (if (car dirs)
- (if (file-exists-p (concat qd ".pc/" (car dirs) "/" file))
- 't
- (editable file (cdr dirs)))
- nil))
+ (fn (quilt-drop-dir f))
+ dirs result)
(if qd
(if (quilt-bottom-p)
(quilt-cmd "applied") ; to print error message
- (editable fn (if quilt-edit-top-only
- (list (quilt-top-patch))
- (cdr (cdr (directory-files (concat qd ".pc/"))))))))))
+ (setq dirs (if quilt-edit-top-only
+ (list (quilt-top-patch))
+ (cdr (cdr (directory-files (concat qd ".pc/"))))))
+ (while (and (not result) dirs)
+ (if (file-exists-p (concat qd ".pc/" (car dirs) "/" fn))
+ (setq result t)
+ (setq dirs (cdr dirs))))
+ result))))
(defun quilt-short-patchname ()
(let ((p (quilt-top-patch)))
@@ -160,25 +163,18 @@
(force-mode-line-update))
(defun quilt-revert ()
- (defun revert-or-hook-buffer ()
- ;; If the file doesn't exist on disk it can't be reverted, but we
- ;; need the revert hooks to run anyway so that the buffer's
- ;; editability will update.
- (if (file-exists-p buffer-file-name)
- (revert-buffer 't 't)
- (run-hooks 'after-revert-hook)))
- (defun revert (buf)
- (save-excursion
- (set-buffer buf)
- (let* ((fn (quilt-buffer-file-name-safe)))
- (if (quilt-p fn)
- (quilt-update-modeline))
- (if (and (quilt-owned-p fn)
- (not (buffer-modified-p)))
- (revert-or-hook-buffer)))))
(dolist (buffer (buffer-list))
(if (not (string-match "^ " (buffer-name buffer)))
- (revert buffer))))
+ (save-excursion
+ (set-buffer buffer)
+ (let* ((fn (quilt-buffer-file-name-safe)))
+ (if (quilt-p fn)
+ (quilt-update-modeline))
+ (if (and (quilt-owned-p fn)
+ (not (buffer-modified-p)))
+ (if (file-exists-p buffer-file-name)
+ (revert-buffer 't 't)
+ (run-hooks 'after-revert-hook))))))))
(defun quilt-push (arg)
"Push next patch, force with prefix arg"