kautz@allegra.UUCP (Henry Kautz) (09/13/88)
After some time trying to figure out how to test if a given string is the name of a buffer, I finally hit upon the following. Note that simply using bufferp doesn't work, because bufferp does not accept a buffer name, only a buffer object. (defun buffer-exists-p (b) "return the buffer object if a buffer named B exists, otherwise nil" (condition-case nil (save-excursion (set-buffer b)) (error nil))) Then I wanted to pop-up, but not switch to, a buffer. The best I could devise is (defun pop-up-buffer (b) "pop up buffer B but don't select it" (let ((c (current-buffer))) (pop-to-buffer b) (pop-to-buffer c))) which has a couple of unfortunate features: (1) it messes up the list of recently visited buffers, and (2) it doesn't work if it's called from a function which is temporarily using a non-displayed buffer. Could someone mail me a better way to code this? ---- Henry Kautz :uucp: allegra!kautz :arpa/internet: kautz%allegra.att.com@research.att.com :csnet: kautz%allegra.att.com@RELAY.CS.NET or kautz%allegra@btl.csnet
merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (09/15/88)
In article <8809141917.AA25173@EDDIE.MIT.EDU>, kautz@allegra (Henry Kautz) writes: | After some time trying to figure out how to test if a given string is | the name of a buffer, I finally hit upon the following. Note that | simply using bufferp doesn't work, because bufferp does not accept a | buffer name, only a buffer object. | | (defun buffer-exists-p (b) | "return the buffer object if a buffer named B exists, | otherwise nil" | (condition-case nil | (save-excursion (set-buffer b)) | (error nil))) How about (defun buffer-exists-p (b) (and (get-buffer b) t)) [if you don't need a 't' return, just (fset 'buffer-exists-p 'get-buffer) is enough] | Then I wanted to pop-up, but not switch to, a buffer. The best I | could devise is | | (defun pop-up-buffer (b) | "pop up buffer B but don't select it" | (let ((c (current-buffer))) | (pop-to-buffer b) | (pop-to-buffer c))) How about (defun pop-up-buffer (b) (display-buffer b t)) From my experience, I have found that GNU Emacs has *most* of what you want already included... it just takes a little horsin' around to find it. I'm waiting for the EMACS-Lisp manual... I hope it helps. -- Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 on contract to BiiN Technical Information Services (for now :-), in a former Intel building in Hillsboro, Oregon, USA <merlyn@intelob.intel.com> or ...!tektronix!inteloa[!intelob]!merlyn Standard disclaimer: I *am* my employer!