FUEL: C-uC-co won't ask for file creation while cycling.

db4
Jose A. Ortega Ruiz 2009-02-22 20:20:46 +01:00
parent c6f2e9365b
commit 90dac6f881
1 changed files with 8 additions and 6 deletions

View File

@ -197,7 +197,7 @@ code in the buffer."
(when (string-match factor-mode--cycle-basename-regex basename) (when (string-match factor-mode--cycle-basename-regex basename)
(cons (match-string 1 basename) (match-string 2 basename)))) (cons (match-string 1 basename) (match-string 2 basename))))
(defun factor-mode--cycle-next (file) (defun factor-mode--cycle-next (file skip)
(let* ((dir (file-name-directory file)) (let* ((dir (file-name-directory file))
(basename (file-name-nondirectory file)) (basename (file-name-nondirectory file))
(p/s (factor-mode--cycle-split basename)) (p/s (factor-mode--cycle-split basename))
@ -211,7 +211,8 @@ code in the buffer."
(let* ((suffix (ring-ref ring (+ i idx))) (let* ((suffix (ring-ref ring (+ i idx)))
(path (expand-file-name (concat prefix suffix) dir))) (path (expand-file-name (concat prefix suffix) dir)))
(when (or (file-exists-p path) (when (or (file-exists-p path)
(and (not (member suffix factor-mode--cycling-no-ask)) (and (not skip)
(not (member suffix factor-mode--cycling-no-ask))
(y-or-n-p (format "Create %s? " path)))) (y-or-n-p (format "Create %s? " path))))
(setq result path)) (setq result path))
(when (and (not factor-mode-cycle-always-ask-p) (when (and (not factor-mode-cycle-always-ask-p)
@ -224,10 +225,11 @@ code in the buffer."
(defsubst factor-mode--cycling-setup () (defsubst factor-mode--cycling-setup ()
(setq factor-mode--cycling-no-ask nil)) (setq factor-mode--cycling-no-ask nil))
(defun factor-mode-visit-other-file (&optional file) (defun factor-mode-visit-other-file (&optional skip)
"Cycle between code, tests and docs factor files." "Cycle between code, tests and docs factor files.
(interactive) With prefix, non-existing files will be skipped."
(let ((file (factor-mode--cycle-next (or file (buffer-file-name))))) (interactive "P")
(let ((file (factor-mode--cycle-next (buffer-file-name) skip)))
(unless file (error "No other file found")) (unless file (error "No other file found"))
(find-file file) (find-file file)
(unless (file-exists-p file) (unless (file-exists-p file)