unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: drain <aeuster@gmail.com>
To: Help-gnu-emacs@gnu.org
Subject: buffer variable values
Date: Sat, 25 Aug 2012 00:33:11 -0700 (PDT)	[thread overview]
Message-ID: <1345879991873-262330.post@n5.nabble.com> (raw)

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.



             reply	other threads:[~2012-08-25  7:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-25  7:33 drain [this message]
2012-08-25  7:52 ` buffer variable values 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345879991873-262330.post@n5.nabble.com \
    --to=aeuster@gmail.com \
    --cc=Help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).