rad@vax5.CIT.CORNELL.EDU (02/06/89)
!@^%@%*!$#!%!!! Excuse me. Good to get that off my chest. Well. Does anyone have something that will let me type 'y' or 'n' in response to any prompt that asks for 'yes' or 'no'? Suffice it to say that I am not at all agreeable with having to type 'yes' and 'no' when 'y' and 'n' would do nicely. (I have been told that UNIX & I go well together; I tend to agree.) I'd give my left arm for a hook/hack/etc. that would do this for me. (Well, maybe not the whole arm, but you get the point. ;^) Many, many, ad infinitum thanks to anyone who can help me with this. (You CAN tell that I just had a run in w/ a 'Please type yes or no.' reply to my 'y' or 'n'; can't you?) -JimC -- Discl. Borrowed account again; Reply-To: is rerouted. Other addressed: batcomputer!cloos@cornell.UUCP; cloos@batcomputer.tn.cornell.edu; cloos@crnlthry.bitnet
lamy@ai.utoronto.ca (Jean-Francois Lamy) (02/06/89)
Redefining yes-or-no-p to invoke y-or-n-p does not solve all problems. emacs.c has direct invocations of the C function for yes-or-no-p (used for confirmation before exit when subprocesses are running, or when buffers have not been saved.). I can live with those particular calls to yes-or-no-p. I guess people who can't could perform these checks prompting with y-or-no-p in the kill-emacs-hook, or dispense with them altogether. Jean-Francois Lamy lamy@ai.utoronto.ca, uunet!ai.utoronto.ca!lamy AI Group, Department of Computer Science, University of Toronto, Canada M5S 1A4
tale@its.rpi.edu (David C Lawrence) (02/06/89)
In article <17901@vax5.CIT.CORNELL.EDU> rad@vax5.CIT.CORNELL.EDU writes:
Well. Does anyone have something that will let me type 'y' or 'n' in
response to any prompt that asks for 'yes' or 'no'? Suffice it to say that
I am not at all agreeable with having to type 'yes' and 'no' when 'y' and
'n' would do nicely. (I have been told that UNIX & I go well together; I
tend to agree.)
I'd give my left arm for a hook/hack/etc. that would do this for me. (Well,
maybe not the whole arm, but you get the point. ;^)
(defun yes-or-no-p (prompt)
"This is -not- the original yes-or-no-p, it is a workaround that
calls y-or-n-p in place of it."
(y-or-n-p prompt))
I'm kind of full up on left arms; would you happen to have a leg to
spare instead?
Dave
--
tale@rpitsmts.bitnet, tale%mts@rpitsgw.rpi.edu, tale@pawl.rpi.edu
jr@bbn.com (John Robinson) (02/06/89)
In article <TALE.89Feb6091941@consult1.its.rpi.edu>, tale@its (David C Lawrence) writes: >In article <17901@vax5.CIT.CORNELL.EDU> rad@vax5.CIT.CORNELL.EDU writes: > >> Well. Does anyone have something that will let me type 'y' or 'n' in >> response to any prompt that asks for 'yes' or 'no'? ... > >> I'd give my left arm for a hook/hack/etc. that would do this for me. (Well, >> maybe not the whole arm, but you get the point. ;^) > >(defun yes-or-no-p (prompt) > "This is -not- the original yes-or-no-p, it is a workaround that >calls y-or-n-p in place of it." > (y-or-n-p prompt)) If you really want to make them the same, right down to the documentation, try: (fset 'yes-or-no-p (symbol-function 'y-or-n-p)) Both of these attempts, however, will fail to change the behavior of uses of this function by C code. This includes: buffer.c:574: tem = Fyes_or_no_p (format1 ("Buffer %s modified; kill anyway? ", emacs.c:452: && (answer = Fyes_or_no_p (format1 ( "%d modified buffer%s exist%s, do you really want to exit? ", emacs.c:461: && (answer = Fyes_or_no_p (format1 ( "Subprocesses are executing; kill them and exit? ")), fileio.c:956: tem = Fyes_or_no_p (format1 ("File %s already exists; %s anyway? ", The latter use is in the function with the flowery name barf_or_query_if_file_exists(), which is called with four completions for the %s in its format string: fileio.c:986: barf_or_query_if_file_exists (newname, "copy to it", fileio.c:1066: barf_or_query_if_file_exists (newname, "rename to it", fileio.c:1114: barf_or_query_if_file_exists (newname, "make it a new name", fileio.c:1152: barf_or_query_if_file_exists (newname, "make it a link", No doubt some of these are the annoying ones. To change them requires modifying the source and recompiling. At that point, maybe a defvar for a user customization would be in order, like say yes_or_no_p_relax. >I'm kind of full up on left arms; would you happen to have a leg to >spare instead? I've got a left hook I'd trade for an arm... -- /jr jr@bbn.com or bbn!jr
jthomas@nmsu.EDU (02/07/89)
>In article <17901@vax5.CIT.CORNELL.EDU> rad@vax5.CIT.CORNELL.EDU writes: > >> Well. Does anyone have something that will let me type 'y' or 'n' in >> response to any prompt that asks for 'yes' or 'no'? ... On the other hand, yes-or-no-p has another difference from y-or-n-p. y-or-n-p reads one and only one character. If it's a "y" or "Y", t, else nil. That includes characters like C-x . I am very happy to be allowed to switch buffers, fix things, etc., in those cases where emacs uses yes-or-no-p , thank you! Jim Thomas jthomas@nmsu.edu
Ram-Ashwin@cs.yale.edu (Ashwin Ram) (02/07/89)
In article <17901@vax5.CIT.CORNELL.EDU>, rad@vax5.CIT.CORNELL.EDU writes: > Well. Does anyone have something that will let me type 'y' or 'n' in > response to any prompt that asks for 'yes' or 'no'? Suffice it to say that > I am not at all agreeable with having to type 'yes' and 'no' when 'y' and > 'n' would do nicely. Me neither. I asked this very question a while ago and I found opinion divided on this point. Although it is painful to have two y/n functions around, the argument went that yes/no provided an extra degree of security for highly destructive functions where it was too easy to hit 'y' (or space) routinely. Some of us disagreed since typing 'yes' routinely is not much harder than typing 'y' routinely, and having two different functions can really get on one's nerves sometimes (as you seem to have found out). My suggestion at the time, and I still think it's a good one, was to get rid of yes-and-no-p and add an optional CONFIRM? argument to y-or-n-p which, if t, would cause it to reconfirm your y/n reply, using the same prompt with "confirm?" added onto the end of it. This is compatible with other uses of confirmation (e.g., filename completion), eliminates the need for users to offer their arms :-), yet retains the extra security that yes-or-no-p is supposed to provide. For compatibility, yes-or-no-p can be retained as a call to y-or-n-p with confirm? = t. Even better, in the Emacs tradition of customizability, the CONFIRM? argument could cause y-or-n-p to invoke a user-definable function which could, by default, behave as yes-or-no-p does now. Then a user could either live with the current state of affairs, or go with the second confirmation prompt as I described above, or just define this function to do nothing and blow away the safety feature if s/he so desired, or do anything else under the sun. I hesitate to state which way is "better" since this is obviously a matter of taste, not functionality. All the more reason for customizability which I trust would make everyone happy. As it stands, the best you can do is to (fset 'yes-or-no-p (symbol-function 'y-or-n-p)), which will not trap pre-compiled calls to yes-or-no-p written in C. -- Ashwin.
jthomas@nmsu.EDU (02/07/89)
In "private" correspondence, Dave (tale%pawl.rpi.edu) asks > I am very happy to be allowed to switch buffers, fix things, etc., in those > cases where emacs uses yes-or-no-p , thank you! > >Could you please explain that line to me? > >I guess what I don't understand is a) which do you like, then? >y-or-n-p all the time or a mixture of that and yes-or-no-p? and b) >why do you have to answer a y(es)-or-n(o)-p prompt to switch buffers? Then I was too obtuse. y-or-n-p reads a single character. yes-or-no-p reads characters. I can switch buffers (C-x C-o) when the questioner uses yes-or-no-p but not when it uses y-or-n-p. The y-or-n-p routine does not allow one to go check things out because C-x is taken as a "no" answer. My point is that they have two differences. One is the length of the answer and the other is what you are allowed to do while answering. So, where I'm not worried about the question, y-or-n-p is fine, but I don't mind having to type yes when I'm possibly in trouble. Jim jthomas@nmsu.edu
Ram-Ashwin@cs.yale.edu (Ashwin Ram) (02/08/89)
In article <8902061849.AA06423@NMSU.Edu>, jthomas@nmsu.EDU writes: > On the other hand, yes-or-no-p has another difference from y-or-n-p. > y-or-n-p reads one and only one character. If it's a "y" or "Y", t, else > nil. That includes characters like C-x . > > I am very happy to be allowed to switch buffers, fix things, etc., in those > cases where emacs uses yes-or-no-p , thank you! Yup, this would be nice to have in y-or-n-p too. Perhaps y-or-n-p should accept 'y' and 'n' (and perhaps space and del) as valid answers, and interpret other keystrokes normally? Then one could switch buffers, fix things, etc., and then come back to the minibuffer and type 'y' or 'n'. -- Ashwin.
cloos@batcomputer.tn.cornell.edu (James H. Cloos Jr.) (02/08/89)
Now that I have cooled down some, I'd like to discuss my thoughts on y-or-n-p vs. yes-or-no-p. One thing that I failed to mention is that I would not mind having to hit return after typing 'y' or 'n' (which would aloow one to C-xo to another window, and do stuff like that). The only thing I don't like is that 'y<RET>' should be equivilent to 'yes<RET>' (& likewise 'n<RET>' == 'no<RET>'). So, I guess the only answer is that I would have to find the c code for yes-or-no-p, and hack it to allow 'y<RET>' to be the same responce as 'yes<RET>' is, etc. I just wanted to make the point that I wasn't expecting the debate that ensued over how yes-or-no-p worked vs. how y-or-n-p did; I just want yes-or-no-p to accept abbreviations. (IMHO, all commands that prompt for a responce, and that do not operate in a mode analogous to UNIX's cbreak mode, should accept abbreviations for their expected input. ALL code that I write keeps this maxim in mind.) P.S. Anyone know if the source for emacs is shipped w/ the NeXTs? -JimC batcomputer!cloos@cornell.UUCP |James H. Cloos, Jr.|#include <disclaimer.h> cloos@batcomputer.tn.cornell.EDU|B7 Upson, Cornell U|#include <cute_stuff.h> cloos@tcgould.tn.cornell.EDU |Ithaca, NY 14853 |"Entropy isn't what cloos@crnlthry.BITNET | +1 607 272 4519 | it used to be." a.k.a. jhc@vax5.ccs.cornell.EDU or jhc@crnlvax5.BITNET (Or, if you'd like to mail me at my NeXT account: jcloos@upson.cit.cornell.edu) (Just don't expect replies as mail comes in but it don't got out. (yet))
derrell@retix.retix.retix.com (Derrell Lipman) (02/09/89)
> Well. Does anyone have something that will let me type 'y' or 'n' in > response to any prompt that asks for 'yes' or 'no'? Suffice it to say that > I am not at all agreeable with having to type 'yes' and 'no' when 'y' and > 'n' would do nicely. (I have been told that UNIX & I go well together; I > tend to agree.) try this in your .emacs file: (defun yes-or-no-p () (y-or-n-p)) -- --derrell (derrell@retix) ------------------------------------------------------------------------------ It must be remembered that there is nothing more difficult to plan, more doubtful of success, nor more dangerous to manage, than the creation of a new system. For the initiator has the enmity of all who would profit by the preservation of the old institutions and merely lukewarm defenders in those who would gain by the new ones. -- Machiavelli
derrell@retix.retix.retix.com (Derrell Lipman) (02/09/89)
(correction to previously posted article regarding 'y or n' instead of 'yes or no') try this in your .emacs file: (defun yes-or-no-p (prompt) (y-or-n-p (prompt)) -- --derrell (derrell@retix) ------------------------------------------------------------------------------ It must be remembered that there is nothing more difficult to plan, more doubtful of success, nor more dangerous to manage, than the creation of a new system. For the initiator has the enmity of all who would profit by the preservation of the old institutions and merely lukewarm defenders in those who would gain by the new ones. -- Machiavelli
ceb@ethz.UUCP (Charles Buckley) (02/14/89)
I have seen a lot of postings asking about this, so here's my hack. This presumes you have some terminal with so-called function keys which transmit some otherwise absolutely useless escape sequence which you can decode, like esc [ M,or something. You define the following functions, and then put in commands which bind these codes to the sequences transmitted by your function keys. On terminals without such keys, you can bind it to simple control keys, to the extend that you don't walk on something already bound there. ;; ;; yes-or-no-keys.el ;; ;; C. Buckley ;; ;; 5 August 1988 ;; ;; We have gotten absolutely used to answering these yes-or-no ;; questions by hitting special keys marked "yes" or "no". This ;; was formerly arranged by loading the terminal with pre-defined ;; strings. Under mux this is not possible. ;; Here we write code to do the same thing. ;; (defun answer-yes-in-minibuffer () "answers yes in minibuffer and terminates minibuffer input." (interactive) (insert "yes") (setq unread-command-char 10) ;a newline ) (defun answer-no-in-minibuffer () "answers no in minibuffer and terminates minibuffer input." (interactive) (insert "no") (setq unread-command-char 10) ;a newline )
ceb@ethz.UUCP (Charles Buckley) (02/14/89)
A followon to my previous posting about yes-or-no . . . (If things run where you are the way they do here, you'll probably see this posting first, so patience) anyway, here it is. One obvious improvement one might make to what I posted (I bet it comes from the Yale people first; it seems their style) would be, in the context of those functions I posted, to check the frame stack and see what function was pending, y-or-n-p or yes-or-no-p, and to do the right thing accordingly. I would do it, but I can't go rooting around in the EMACS guts right now to find out how to get at the frame-stack if at all. If not possible, it would also be doable by defining yet another global state variable, but I have learned to shy away from this kind of thing. If you did define the global variable, you could also fix it so the functions had no effect when neither one was pending. That's it.
rbj@nav.icst.nbs.GOV (Root Boy Jim) (03/11/89)
? >I'm kind of full up on left arms; would you happen to have a leg to ? >spare instead? ? I've got a left hook I'd trade for an arm... I have scanned thru the documentation for left-mode and left-hook, but could not find a reference to either. Perhaps it is used in farsi-mode? ? jr@bbn.com or bbn!jr Catman Rshd <rbj@nav.icst.nbs.gov> Author of "The Daemonic Versions"