(defun tmp:interactive (&optional scope pos-style)
"POS-STYLE has no effect when SCOPE is `directory'."
(interactive
(list
(cdr (assoc (read-char-choice
"Copy (f)ull name, (d)irectory, or just the (b)asename? "
'(?f ?d ?b))
'((?f . full)
(?d . directory)
(?b . basename))))
(when (and (not (equal scope 'directory)) current-prefix-arg)
(cdr (assoc (read-char-choice
"Style: (n)one, (l)ine, (c)olumn, or (p)oint? "
'(?n ?l ?c ?p))
'((?n . nil)
(?l . line)
(?c . line-column)
(?p . point)))))))
(message "%S %S" scope pos-style))
Above is a skeleton of a function that copies the appropriate file name for the current buffer. However, it doesn't really make sense to include position information when the user is copying the directory name.
Is there a way to ignore a prefix argument within the (interactive ...)
form based on previous input?
(An alternative solution to this end would be to test called-interactively-p
and leave the optional argument as nil to test in the body of the defun
, but that's very fragmented.