all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Format-alist vs. minor mode
@ 2008-08-01 10:45 tomas
  2008-08-01 12:26 ` martin rudalics
  2008-08-03 17:47 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: tomas @ 2008-08-01 10:45 UTC (permalink / raw)
  Cc: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm trying to switch on a minor mode via the format-alist feature, like
so:

  (add-to-list 'format-alist
               (list "ZEIT-k4c"
                     "ZEIT k4 cooked XML"
                     "^<\\?xml[^>]*>[^<]*<article>"
                     'am-parse-region
                     'am-unparse-region
                     t
                     'am-mode)
               nil
               (lambda (x y) (equal (car x) (car y))))

It works at first, when the regexp is recognized the mode function is
called... but then "fundamental-mode" sets in, kills all local variables
and reverts the minor mode settings.

What am I doing wrong? Do only major modes work with format-alist?

Thanks
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIkulbBcgs9XrR2kYRAgpvAJ9LsoGl/L1YyyKxrQhkL1HHkEAIlgCfR6tn
ivpezzABebPH9+j4I1+eTsU=
=7Gd0
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format-alist vs. minor mode
  2008-08-01 10:45 Format-alist vs. minor mode tomas
@ 2008-08-01 12:26 ` martin rudalics
  2008-08-01 13:17   ` tomas
  2008-08-03 17:47 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: martin rudalics @ 2008-08-01 12:26 UTC (permalink / raw)
  To: tomas; +Cc: emacs-devel

 > It works at first, when the regexp is recognized the mode function is
 > called... but then "fundamental-mode" sets in, kills all local variables
 > and reverts the minor mode settings.

I'm using an `after-change-major-mode-hook' but there are a couple of
glitches.  Look at the speck.el file I sent to emacs-sources a few days
ago and search for `format-alist'.

http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-07/msg00018.html





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format-alist vs. minor mode
  2008-08-01 12:26 ` martin rudalics
@ 2008-08-01 13:17   ` tomas
  0 siblings, 0 replies; 6+ messages in thread
From: tomas @ 2008-08-01 13:17 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Aug 01, 2008 at 02:26:31PM +0200, martin rudalics wrote:
> > [...] but then "fundamental-mode" sets in, kills all local variables
> > and reverts the minor mode settings.
>
> I'm using an `after-change-major-mode-hook' but there are a couple of
> glitches.  Look at the speck.el file I sent to emacs-sources a few days
> ago and search for `format-alist'.
>
> http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-07/msg00018.html

Thanks for the pointer. So I'm not alone with this "problem". How is
that actually supposed to work?

I'll have a peek at speck.el

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIkwz7Bcgs9XrR2kYRAnsBAJ9jCWAQRsXhZzsVYpmNXebNTe5ClwCeJYcH
L84zRvi1+EHr1sUWddX9Uko=
=9RA5
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format-alist vs. minor mode
  2008-08-01 10:45 Format-alist vs. minor mode tomas
  2008-08-01 12:26 ` martin rudalics
@ 2008-08-03 17:47 ` Stefan Monnier
  2008-08-03 18:01   ` tomas
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2008-08-03 17:47 UTC (permalink / raw)
  To: tomas; +Cc: emacs-devel

> I'm trying to switch on a minor mode via the format-alist feature, like
> so:

>   (add-to-list 'format-alist
>                (list "ZEIT-k4c"
>                      "ZEIT k4 cooked XML"
>                      "^<\\?xml[^>]*>[^<]*<article>"
>                      'am-parse-region
>                      'am-unparse-region
>                      t
>                      'am-mode)
>                nil
>                (lambda (x y) (equal (car x) (car y))))

> It works at first, when the regexp is recognized the mode function is
> called... but then "fundamental-mode" sets in, kills all local variables
> and reverts the minor mode settings.

> What am I doing wrong? Do only major modes work with format-alist?

If the minor mode depends on the file/buffer's contents, then it should
survive a change in major-mode, right?  So you might want to make your
minor mode permanent-local.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format-alist vs. minor mode
  2008-08-03 17:47 ` Stefan Monnier
@ 2008-08-03 18:01   ` tomas
  2008-08-04 19:02     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: tomas @ 2008-08-03 18:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: tomas, emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Aug 03, 2008 at 01:47:16PM -0400, Stefan Monnier wrote:
> > I'm trying to switch on a minor mode via the format-alist feature, like

> > It works at first, when the regexp is recognized the mode function is
> > called... but then "fundamental-mode" sets in, kills all local variables

[...]

> If the minor mode depends on the file/buffer's contents, then it should
> survive a change in major-mode, right?  So you might want to make your
> minor mode permanent-local.

Thanks, Stefan. I figured that out thanks to the pointers provided by
Martin Rudalics. It was very surprising at the beginning :-)

I guess one wants to do that almost always when doing format
transformations à la format-alist, although those things are not very
related. This explains the misleading subject line.

Do you think a pointer in the doc is appropriate?

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIlfJxBcgs9XrR2kYRAi34AJ9KqWJ09gXFN8x4um3K/MFnMfmTsgCfYcvj
kiTyi4a0tw+pkI4ywJTTkfg=
=UX68
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format-alist vs. minor mode
  2008-08-03 18:01   ` tomas
@ 2008-08-04 19:02     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2008-08-04 19:02 UTC (permalink / raw)
  To: tomas; +Cc: emacs-devel

> I guess one wants to do that almost always when doing format
> transformations à la format-alist, although those things are not very
> related. This explains the misleading subject line.

> Do you think a pointer in the doc is appropriate?

Could be.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-04 19:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-01 10:45 Format-alist vs. minor mode tomas
2008-08-01 12:26 ` martin rudalics
2008-08-01 13:17   ` tomas
2008-08-03 17:47 ` Stefan Monnier
2008-08-03 18:01   ` tomas
2008-08-04 19:02     ` Stefan Monnier

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.