[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: How to put information (first items) from Chang
From: |
Michael Olson |
Subject: |
[emacs-wiki-discuss] Re: How to put information (first items) from Changelog on another published WikiPage |
Date: |
Tue, 11 Jan 2005 20:12:20 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
Jean-Philippe Georget <address@hidden> writes:
> Michael Olson <address@hidden> a écrit :
>
>> Jean-Philippe Georget <address@hidden> writes:
>>
>>> I use Changelog feature to give information about the modifications
>>> of my website. Now I want to put the first items of this file (for
>>> example the 4 first items) on the published WelcomePage.
>>
> [...]
>> I'll experiment over Christmas Break with this idea (and try to make
>> it generally useful, so ChangeLogs can work also). I wonder what a
>> good name for this functionality might be ... hmm.
I made a function that takes the first 4 entries from your ChangeLog
file. I'm not sure where to put this yet, so here it is.
(defun my-get-changelog-entries (num-entries)
"Return the most recent entries from the ChangeLog file.
It will look in the current directory for this file. The number
of entries is determined by NUM-ENTRIES.
You can put <lisp>(my-get-changelog-entries)</lisp> in a Wiki
file to make use of this function."
(interactive)
(let* ((file "ChangeLog")
(regexp "^[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}")
beginning end buffer-opened-already buffer str)
(save-excursion
(save-match-data
(setq buffer-opened-already (get-file-buffer file))
(setq buffer (set-buffer (find-file-noselect file)))
(goto-char (point-min))
(when (re-search-forward regexp nil t)
(setq beginning (match-beginning 0))
(while (and (> num-entries 0)
(re-search-forward regexp
nil 1))
(setq num-entries (1- num-entries)))
(beginning-of-line)
(backward-char)
(setq end (point)))))
(and beginning end
(with-current-buffer buffer
(setq str (buffer-substring beginning end))))
(unless buffer-opened-already
(kill-buffer buffer))
str))
For this particular case, you could put a lisp snippet on your
WelcomePage that looks something like:
<lisp>(my-get-changelog-entries)</lisp>
--
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Jabber: mwolson_at_hcoop.net -- IRC: mwolson on freenode.net: #muse, #pulug
/~ |\ | | | Interests: animé, Debian GNU/Linux, XHTML, wiki, Lisp
|_] | \| |_| Fun quotes: http://www.mwolson.org/plans/QuoteList.html
pgp24tPGBV18q.pgp
Description: PGP signature
- [emacs-wiki-discuss] Re: How to put information (first items) from Changelog on another published WikiPage,
Michael Olson <=