unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "B. T. Raven" <nihil@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Why won't this command kill a buffer?
Date: Mon, 14 Feb 2011 20:23:00 -0600	[thread overview]
Message-ID: <p9adnSQl1pwZfsTQnZ2dnUVZ_oOdnZ2d@sysmatrix.net> (raw)
In-Reply-To: <u4o88vpdc.fsf@verizon.net>

Joe Fineman wrote:
> "B. T. Raven" <nihil@nihilo.net> writes:
> 
>> If you really mean "append" (put at the end) then this works
>> (on msw2000 with Emacs 22.3):
>>
>> "
>> append-to-file is an interactive compiled Lisp function in `files.el'.
>> It is bound to <f4>.
>> (append-to-file START END FILENAME)
>>
>> Append the contents of the region to the end of file FILENAME.
>> When called from a function, expects three arguments,
>> START, END and FILENAME.  START and END are buffer positions
>> saying what text to write.
>> "
>>
>> Interactively I had bound this function to f4 in .emacs
>> (define-key global-map [f4] 'append-to-file)
>> I made a test file with a few chars in it and saved it.
>> Inserted backspace into buffer with C-q *backspacekey* and then made
>> that single character (shows as ^?) the region and pressed f4.
>> Inspection of the last character of the file appended to shows:
>>
>> Char: DEL (127, #o177, #x7f) point=5 of 5 (80%) column=0
>>
>> I assume that what can be done interactively can also be done
>> programmatically.
> 
> Thank you.  I will give that a try.  It may turn out to be a nuisance,
> tho, that it requires inserting the character in the current buffer &
> then deleting it.  The function I defined is usually run in the
> background, and it might cause confusion in that it would cause the
> current buffer to be marked as modified, and might interact oddly with
> my keying.  What I would really like is an append-to-file command that
> takes as its argument an arbitrary character or string, rather than a
> substring of the current buffer.


It looks like Emacs sees such a procedure as too low-level. Since it
operates on files in buffers you would have to do
find-file-other-window, select-window, (goto-char (point-max)) and then
insert the char. I haven't been able to insert \ via elisp though. All
the functions produce 92, \nil, or "\\" or worse. I thought of creating
a file with only backslash in it and then running (shell-command "cat
file bacsla >> file") but if you need the character parameterized then
you need to shell-command on a program that does fputc on the file
opened for append.


  reply	other threads:[~2011-02-15  2:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11 22:48 Why won't this command kill a buffer? Joe Fineman
2011-02-12  4:15 ` B. T. Raven
2011-02-12  4:19   ` B. T. Raven
2011-02-12 22:50   ` Joe Fineman
2011-02-15  2:23     ` B. T. Raven [this message]
2011-02-16 14:27       ` B. T. Raven
2011-02-12  7:47 ` Le Wang
     [not found] ` <mailman.1.1297496838.19060.help-gnu-emacs@gnu.org>
2011-02-12 23:05   ` Joe Fineman
2011-02-13  7:07     ` Le Wang

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=p9adnSQl1pwZfsTQnZ2dnUVZ_oOdnZ2d@sysmatrix.net \
    --to=nihil@nihilo.net \
    --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).