Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site calmasd.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcc3!sdcc6!calmasd!cdh From: cdh@calmasd.UUCP (C. Douglas Hodges) Newsgroups: net.emacs Subject: Re: a simple problem for 4.2 gosling-emacs Message-ID: <388@calmasd.UUCP> Date: Fri, 10-May-85 13:31:08 EDT Article-I.D.: calmasd.388 Posted: Fri May 10 13:31:08 1985 Date-Received: Mon, 13-May-85 02:24:16 EDT References: <271@sbcs.UUCP> Reply-To: cdh@calmasd.UUCP (C. Douglas Hodges) Distribution: net Organization: Calma Company, San Diego, CA Lines: 61 Keywords: get-tty-buffer > >From: podar@sbcs.UUCP (Sunil Podar) > Subject: a simple problem for 4.2 gosling-emacs > Date: 4 May 85 02:56:40 GMT > Organization: Computer Science Dept, SUNY@Stony Brook > > I wanted to write a very simple mlisp function, but couldn't get it to do > what I wanted; This is for Gosling emacs on 4.2BSD. > Here is what I eventually settled with: > ;------------------------------------- > (defun (forget-it buff-name > (setq buff-name (get-tty-string (concat ": delete-buffer [" > (current-buffer-name) "] "))) > (if (= buff-name "") > (delete-buffer (current-buffer-name)) > (delete-buffer buff-name)))) > ;;;------------------------------------- > > The problem is that I wanted to use "get-tty-buffer" in place of > "get-tty-string" so that name-completion would be provided, which is > a very useful (& sometimes essential) feature for many buffer names are > often very cryptic (e.g. **Scratch Stuff**) and "get-tty-string" needs > to have the entire name specified exactly. Moreover I wanted to provide > a default for which you merely had to press , ....... I think the following does what you desire: (defun ; prompts the user for a buffer name (similar to "get-tty-buffer") ; except that it provides two ways to default to the current buffer: ; -- immediate default to current buffer name ; space, escape -- expand the current buffer name out for the user ; but do not return (give a chance to change it) (get-tty-buf-w/-default char buf-name prompt (if (error-occurred (setq prompt (arg 1))) (setq prompt ": buffer-name ") ) (message prompt) (setq char (get-tty-character)) (if (= char '\^M') (setq buf-name (current-buffer-name)) (progn (if (| (= char ' ') (= char '\e')) (push-back-string (current-buffer-name)) (push-back-character char) ) (setq buf-name (get-tty-buffer prompt)) ) ) buf-name ) ) (defun (forget-it (delete-buffer (get-tty-buf-w/-default ": delete-buffer ")) ) )