From: Le Wang <l26wang@gmail.com>
To: Joe Fineman <joe_f@verizon.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Why won't this command kill a buffer?
Date: Sat, 12 Feb 2011 15:47:11 +0800 [thread overview]
Message-ID: <AANLkTinHVD5z_3w0F9gji-xL8HSJGeX8OCv8fuQ14h9V@mail.gmail.com> (raw)
In-Reply-To: <ubp2iur0p.fsf@verizon.net>
[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]
On Sat, Feb 12, 2011 at 6:48 AM, Joe Fineman <joe_f@verizon.net> wrote:
> I am using Emacs 22.3.1 under Windows XP. I have used the following
> kluge for many years:
>
> (defun marklog ()
> "Insert a backslash into the Log file for the current directory, and into
> Today if it is in /b."
> (interactive)
> (save-window-excursion
> (let ((dir default-directory)
> (require-final-newline))
> (find-file "~/timing/Logmark")
> (write-region 1 2 (concat dir "Log") t 0)
> (if (equal (substring dir 0 15) "c:/usr/own/f/b/")
> (write-region 1 2 "~/b/Today" t 0))
> (kill-this-buffer))
> ))
>
> The Logmark file consists of a single backslash.
>
> The command kill-this-buffer does not work, and neither do attempts to
> use kill-buffer with an argument. The buffer hangs around and is
> sometimes a nuisance.
>
I'm really not sure what the above is supposed to do. Maybe you can come up
with minimum set of steps that repros what you're seeing.
> And, incidentally, is there any simpler way to tell Emacs to append a
> character to a file?
>
I don't think so. But you can come up with one easily:
(defun append-str-to-file (str filename)
"Append a string to the end of a file.
If the file is being visited, don't save or kill it."
(interactive "sstring: \nFfile: ")
(let ((visiting-buffer (find-buffer-visiting filename))
require-final-newline)
(with-current-buffer (or visiting-buffer
(find-file-noselect filename))
(save-excursion
(goto-char (point-max))
(insert str)
(unless visiting-buffer
(save-buffer)
(kill-this-buffer))))))
--
Le
[-- Attachment #2: Type: text/html, Size: 3008 bytes --]
next prev parent reply other threads:[~2011-02-12 7:47 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
2011-02-16 14:27 ` B. T. Raven
2011-02-12 7:47 ` Le Wang [this message]
[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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinHVD5z_3w0F9gji-xL8HSJGeX8OCv8fuQ14h9V@mail.gmail.com \
--to=l26wang@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=joe_f@verizon.net \
/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.
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.