Re: Another changelog rant
> Wichert Akkerman wrote:
> > Previously Peter S Galbraith wrote:
> > > The "mode: debian-changelog" line is still useful for Debian
> > > native packages because the mode gets invoked properly when you
> > > edit an installed log file,
> > > e.g. /usr/share/doc/debiandoc-sgml/changelog.gz
> > > (It's not named changelog.Debian.gz so we can't autoload based on
> > > the name)
> > But you can easily view the type based on a regexp match on the
> > first line
> How do you do that in Emacs?
> > (vim does that :)
> > Wichert.
> Oh, so you were just trolling. Too bad. I thought you were on
> to something.
Alan Shutko wrote:
> I'd put something in change-log-mode-hook which does the check, and
> sets major-mode appropriately. Unfortunately, interpreter-mode-alist
> is specific to files which start with #!.
This is interesting. I like it!
Matt Zimmerman wrote:
> You have to add -*- magic to the first line of the file. Unfortunately, I
> don't think the Debian changelog format has room for a comment there.
And it defeats the purpose. We want to delete the existing
entries, not add different ones.
Wichert Akkerman wrote:
> I was not trolling, I just pointed out that there is a simple way
> to distinguish between the files that emacs could also use. The
> fact that vim does that already only shows that it can indeed be
Okay. It's sometimes hard to the sense or tone in email. I just
want to be able to do it without patching Emacs itself (so we can
use it right away).
> (mapcar #'(lambda (element)
> (setq auto-mode-alist
> (cons element auto-mode-alist)))
> '(("/linux/.*\\.[ch]\\'" . linux-c-mode)
> ("/usr/share/doc/changelog\\..*" . debian-changelog-mode)))
> Something along the above in your ~/.emacs or better let dpkg-dev-el
> to handle it. But vim's approach is interesting too, I bet emacs will
> have this ability added soon. ;)
We already use a similar scheme in /etc/emacs/site-start.d/50dpkg-dev.el
to load debian-changelog-mode on changelog.Debian.gz files. But we
don't want to load debian-changelog-mode on an upstream
/usr/share/doc/changelog.gz file, only on Debian native ones. We can't
use the name to tell them apart.
Tollef Fog Heen wrote:
> Something like:
> (setq find-file-hooks
> (cons #'(lambda ()
> ;; Invoke proper modes when we don't know file extensions
> (cond ((looking-at "#!.*/perl") (perl-mode))
> ((looking-at "#!.*/tclsh") (tcl-mode))
> ((looking-at "#!.*/wish") (tcl-mode))))
> And add the proper regexp for Debian changelogs.
Done with add-hook instead of setq, this is an interesting answer.
Thanks all! I have two good candidates to try out. I'm sure we'll soon
be able to remove all traces of the local variable block from changelogs
without losing any benefit.