all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* buffer variable values
@ 2012-08-25  7:33 drain
  2012-08-25  7:52 ` PJ Weisberg
       [not found] ` <mailman.7566.1345906894.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: drain @ 2012-08-25  7:33 UTC (permalink / raw)
  To: Help-gnu-emacs

Original insert-buffer function:

(defun insert-buffer (buffer)
  "Insert after point the contents of BUFFER.
  Puts mark after the inserted text.
  BUFFER may be a buffer or a buffer name."
  (interactive "*bInsert buffer: ")
  (or (bufferp buffer)
      (setq buffer (get-buffer buffer)))
  (let (start end newmark)
    (save-excursion
      (save-excursion
	(set-buffer buffer)
	(setq start (point-min) end (point-max)))
      (insert-buffer-substring buffer start end)
      (setq newmark (point)))
    (push-mark newmark)))

Under what conditions would (or (bufferp buffer) not be nil?

In the Emacs Lisp Intro, in the discussion of this function, there seem to
be three different "buffer" variable values referred to:

(assuming "web.org" is an existing buffer):

(1) #<buffer web.org> 
(2) web.org
(3) web

(1) is what setq assigns "buffer" in the expression (setq buffer (get-buffer
buffer)).
(2) is the name of an existing buffer that the interactive expression will
permit the user to enter.
(3) is a string that refers to no buffers.

I don't understand the point in the OR expression. How would the user pass
as argument to the function a buffer, rather than just the name of a buffer?
Entering #<buffer web.org> is invalid. 

If this function did not read input from the user, the OR expression would
serve a purpose; since "buffer" could have been assigned an actual buffer
elsewhere in the body of a larger function (that insert-buffer had been
embedded into).




--
View this message in context: http://emacs.1067599.n5.nabble.com/buffer-variable-values-tp262330.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-25 19:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-25  7:33 buffer variable values drain
2012-08-25  7:52 ` PJ Weisberg
2012-08-25  8:14   ` drain
2012-08-25 15:01     ` Drew Adams
     [not found]   ` <mailman.7557.1345882485.855.help-gnu-emacs@gnu.org>
2012-08-25 14:38     ` Barry Margolin
     [not found] ` <mailman.7566.1345906894.855.help-gnu-emacs@gnu.org>
2012-08-25 18:08   ` Barry Margolin
2012-08-25 19:40     ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.