From: peter at exegenix.com (Peter Mielke)
Subject: [Howm-eng 21] Set buffer name of Howm file
Date: Thu, 23 Feb 2006 09:29:06 -0500 (EST) [thread overview]
Message-ID: <20060223142906.2CCE25A704@yen.exegenix.com> (raw)
Hi,
I've just started using howm and enjoy it. Here is a snippet that i
wrote to set the buffer name to the title at the start of the
file. This to me is much more useful than knowing the filename.
Comments?
(defun my-howm-mode-set-buffer-name ()
"Set the buffer name to the title at the top of the file."
(save-excursion
(goto-char 0)
(if (and (buffer-file-name)
(string-match "\\.howm" (buffer-name))
(looking-at "= *\\(.*\\)"))
(let ((title (buffer-substring-no-properties (match-beginning 1)
(match-end 1))))
(if (< 0 (length title))
;; check for a buffer with the same name
(let* ((pat (concat "^" (regexp-quote title) "\\(<.*\\|\\)$"))
(count (eval (cons '+
(mapcar '(lambda (x) (if (string-match pat x) 1 0))
(mapcar 'buffer-name (delq (current-buffer) (buffer-list))))))))
(if (= 0 count)
(rename-buffer title)
(rename-buffer (concat title "<" (int-to-string count) ">")))))))))
(add-hook 'howm-mode-hook 'my-howm-mode-set-buffer-name)
reply other threads:[~2006-02-23 14:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060223142906.2CCE25A704@yen.exegenix.com \
--to=howm-eng@lists.osdn.me \
/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 NNTP newsgroup(s).