* abbrev table in cperl-mode
@ 2010-04-16 11:27 Leo
2010-04-16 19:12 ` Ilya Zakharevich
0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2010-04-16 11:27 UTC (permalink / raw)
To: emacs-devel; +Cc: Ilya Zakharevich
Hello Ilya,
Is it intended for the abbrevs defined in cperl-mode to be saved to the
abbrev file i.e. these:
......
(let ((prev-a-c abbrevs-changed))
(define-abbrev-table 'cperl-mode-abbrev-table '(
("if" "if" cperl-electric-keyword 0)
("elsif" "elsif" cperl-electric-keyword 0)
("while" "while" cperl-electric-keyword 0)
("until" "until" cperl-electric-keyword 0)
("unless" "unless" cperl-electric-keyword 0)
("else" "else" cperl-electric-else 0)
("continue" "continue" cperl-electric-else 0)
("for" "for" cperl-electric-keyword 0)
("foreach" "foreach" cperl-electric-keyword 0)
("formy" "formy" cperl-electric-keyword 0)
("foreachmy" "foreachmy" cperl-electric-keyword 0)
("do" "do" cperl-electric-keyword 0)
("=pod" "=pod" cperl-electric-pod 0)
("=over" "=over" cperl-electric-pod 0)
("=head1" "=head1" cperl-electric-pod 0)
("=head2" "=head2" cperl-electric-pod 0)
("pod" "pod" cperl-electric-pod 0)
("over" "over" cperl-electric-pod 0)
("head1" "head1" cperl-electric-pod 0)
("head2" "head2" cperl-electric-pod 0)))
(setq abbrevs-changed prev-a-c))
......
It seems a bit better to define them as system abbrevs.
Leo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev table in cperl-mode
2010-04-16 11:27 abbrev table in cperl-mode Leo
@ 2010-04-16 19:12 ` Ilya Zakharevich
2010-04-16 20:11 ` Leo
0 siblings, 1 reply; 6+ messages in thread
From: Ilya Zakharevich @ 2010-04-16 19:12 UTC (permalink / raw)
To: Leo; +Cc: emacs-devel
On Fri, Apr 16, 2010 at 12:27:05PM +0100, Leo wrote:
> Hello Ilya,
>
> Is it intended for the abbrevs defined in cperl-mode to be saved to the
> abbrev file i.e. these:
>
> ......
> (let ((prev-a-c abbrevs-changed))
> (define-abbrev-table 'cperl-mode-abbrev-table '(
> ("if" "if" cperl-electric-keyword 0)
> ("elsif" "elsif" cperl-electric-keyword 0)
> ("while" "while" cperl-electric-keyword 0)
> ("until" "until" cperl-electric-keyword 0)
> ("unless" "unless" cperl-electric-keyword 0)
> ("else" "else" cperl-electric-else 0)
> ("continue" "continue" cperl-electric-else 0)
> ("for" "for" cperl-electric-keyword 0)
> ("foreach" "foreach" cperl-electric-keyword 0)
> ("formy" "formy" cperl-electric-keyword 0)
> ("foreachmy" "foreachmy" cperl-electric-keyword 0)
> ("do" "do" cperl-electric-keyword 0)
> ("=pod" "=pod" cperl-electric-pod 0)
> ("=over" "=over" cperl-electric-pod 0)
> ("=head1" "=head1" cperl-electric-pod 0)
> ("=head2" "=head2" cperl-electric-pod 0)
> ("pod" "pod" cperl-electric-pod 0)
> ("over" "over" cperl-electric-pod 0)
> ("head1" "head1" cperl-electric-pod 0)
> ("head2" "head2" cperl-electric-pod 0)))
> (setq abbrevs-changed prev-a-c))
> ......
>
> It seems a bit better to define them as system abbrevs.
I trust your word for this. ;-) What you see is the "I implemented
it the way I could - given my very limited understanding of
abbreviation tables" approach.
Try to educate me more,
Ilya
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev table in cperl-mode
2010-04-16 19:12 ` Ilya Zakharevich
@ 2010-04-16 20:11 ` Leo
2010-04-17 4:48 ` Ilya Zakharevich
0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2010-04-16 20:11 UTC (permalink / raw)
To: Ilya Zakharevich; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 2197 bytes --]
On 16 April 2010 20:12, Ilya Zakharevich <ilya@math.berkeley.edu> wrote:
> On Fri, Apr 16, 2010 at 12:27:05PM +0100, Leo wrote:
>> Hello Ilya,
>>
>> Is it intended for the abbrevs defined in cperl-mode to be saved to the
>> abbrev file i.e. these:
>>
>> ......
>> (let ((prev-a-c abbrevs-changed))
>> (define-abbrev-table 'cperl-mode-abbrev-table '(
>> ("if" "if" cperl-electric-keyword 0)
>> ("elsif" "elsif" cperl-electric-keyword 0)
>> ("while" "while" cperl-electric-keyword 0)
>> ("until" "until" cperl-electric-keyword 0)
>> ("unless" "unless" cperl-electric-keyword 0)
>> ("else" "else" cperl-electric-else 0)
>> ("continue" "continue" cperl-electric-else 0)
>> ("for" "for" cperl-electric-keyword 0)
>> ("foreach" "foreach" cperl-electric-keyword 0)
>> ("formy" "formy" cperl-electric-keyword 0)
>> ("foreachmy" "foreachmy" cperl-electric-keyword 0)
>> ("do" "do" cperl-electric-keyword 0)
>> ("=pod" "=pod" cperl-electric-pod 0)
>> ("=over" "=over" cperl-electric-pod 0)
>> ("=head1" "=head1" cperl-electric-pod 0)
>> ("=head2" "=head2" cperl-electric-pod 0)
>> ("pod" "pod" cperl-electric-pod 0)
>> ("over" "over" cperl-electric-pod 0)
>> ("head1" "head1" cperl-electric-pod 0)
>> ("head2" "head2" cperl-electric-pod 0)))
>> (setq abbrevs-changed prev-a-c))
>> ......
>>
>> It seems a bit better to define them as system abbrevs.
>
> I trust your word for this. ;-) What you see is the "I implemented
> it the way I could - given my very limited understanding of
> abbreviation tables" approach.
Generally I think program should define system abbrevs to
differentiate from abbrevs defined by the user. And each time
define-abbrev-* runs, the abbrev definitions are overwritten anyway.
The attached patch does this. BTW, defining system abbrevs doesn't
change abbrev-changed so I leave the (let ...) out.
> Try to educate me more,
> Ilya
Leo
[-- Attachment #2: 0001-Fix-cperl-mode-abbrevs.patch --]
[-- Type: application/octet-stream, Size: 2869 bytes --]
From 45bee4e80314563243b71a710beaae7a2d8ece26 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@gmail.com>
Date: Fri, 16 Apr 2010 21:09:01 +0100
Subject: [PATCH] Fix cperl-mode abbrevs
---
lisp/progmodes/cperl-mode.el | 44 ++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 2f751f2..10d5bf3 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1714,29 +1714,27 @@ or as help on variables `cperl-tips', `cperl-problems',
[(control c) (control h) f])))
(setq major-mode cperl-use-major-mode)
(setq mode-name "CPerl")
- (let ((prev-a-c abbrevs-changed))
- (define-abbrev-table 'cperl-mode-abbrev-table '(
- ("if" "if" cperl-electric-keyword 0)
- ("elsif" "elsif" cperl-electric-keyword 0)
- ("while" "while" cperl-electric-keyword 0)
- ("until" "until" cperl-electric-keyword 0)
- ("unless" "unless" cperl-electric-keyword 0)
- ("else" "else" cperl-electric-else 0)
- ("continue" "continue" cperl-electric-else 0)
- ("for" "for" cperl-electric-keyword 0)
- ("foreach" "foreach" cperl-electric-keyword 0)
- ("formy" "formy" cperl-electric-keyword 0)
- ("foreachmy" "foreachmy" cperl-electric-keyword 0)
- ("do" "do" cperl-electric-keyword 0)
- ("=pod" "=pod" cperl-electric-pod 0)
- ("=over" "=over" cperl-electric-pod 0)
- ("=head1" "=head1" cperl-electric-pod 0)
- ("=head2" "=head2" cperl-electric-pod 0)
- ("pod" "pod" cperl-electric-pod 0)
- ("over" "over" cperl-electric-pod 0)
- ("head1" "head1" cperl-electric-pod 0)
- ("head2" "head2" cperl-electric-pod 0)))
- (setq abbrevs-changed prev-a-c))
+ (define-abbrev-table 'cperl-mode-abbrev-table
+ '(("if" "if" cperl-electric-keyword 0 t)
+ ("elsif" "elsif" cperl-electric-keyword 0 t)
+ ("while" "while" cperl-electric-keyword 0 t)
+ ("until" "until" cperl-electric-keyword 0 t)
+ ("unless" "unless" cperl-electric-keyword 0 t)
+ ("else" "else" cperl-electric-else 0 t)
+ ("continue" "continue" cperl-electric-else 0 t)
+ ("for" "for" cperl-electric-keyword 0 t)
+ ("foreach" "foreach" cperl-electric-keyword 0 t)
+ ("formy" "formy" cperl-electric-keyword 0 t)
+ ("foreachmy" "foreachmy" cperl-electric-keyword 0 t)
+ ("do" "do" cperl-electric-keyword 0 t)
+ ("=pod" "=pod" cperl-electric-pod 0 t)
+ ("=over" "=over" cperl-electric-pod 0 t)
+ ("=head1" "=head1" cperl-electric-pod 0 t)
+ ("=head2" "=head2" cperl-electric-pod 0 t)
+ ("pod" "pod" cperl-electric-pod 0 t)
+ ("over" "over" cperl-electric-pod 0 t)
+ ("head1" "head1" cperl-electric-pod 0 t)
+ ("head2" "head2" cperl-electric-pod 0 t)))
(setq local-abbrev-table cperl-mode-abbrev-table)
(if (cperl-val 'cperl-electric-keywords)
(abbrev-mode 1))
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: abbrev table in cperl-mode
2010-04-16 20:11 ` Leo
@ 2010-04-17 4:48 ` Ilya Zakharevich
2010-04-17 11:21 ` Leo
2010-04-17 14:42 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Ilya Zakharevich @ 2010-04-17 4:48 UTC (permalink / raw)
To: Leo; +Cc: emacs-devel
On Fri, Apr 16, 2010 at 09:11:15PM +0100, Leo wrote:
> The attached patch does this. BTW, defining system abbrevs doesn't
> change abbrev-changed so I leave the (let ...) out.
The docs for my version say
define-abbrev-table: a built-in function.
Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of
elements
of the form (ABBREVNAME EXPANSION HOOK USECOUNT).
(define-abbrev-table TABLENAME DEFINITIONS)
So, as minimum, it is not backward-compatible.
Hope this helps,
Ilya
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev table in cperl-mode
2010-04-17 4:48 ` Ilya Zakharevich
@ 2010-04-17 11:21 ` Leo
2010-04-17 14:42 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Leo @ 2010-04-17 11:21 UTC (permalink / raw)
To: Ilya Zakharevich; +Cc: emacs-devel
On 2010-04-17 05:48 +0100, Ilya Zakharevich wrote:
> The docs for my version say
>
> define-abbrev-table: a built-in function.
>
> Define TABLENAME (a symbol) as an abbrev table name.
> Define abbrevs in it according to DEFINITIONS, which is a list of
> elements
> of the form (ABBREVNAME EXPANSION HOOK USECOUNT).
>
> (define-abbrev-table TABLENAME DEFINITIONS)
>
> So, as minimum, it is not backward-compatible.
I guess that's pre-22. It's up to you whether to support them though.
Leo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: abbrev table in cperl-mode
2010-04-17 4:48 ` Ilya Zakharevich
2010-04-17 11:21 ` Leo
@ 2010-04-17 14:42 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2010-04-17 14:42 UTC (permalink / raw)
To: Ilya Zakharevich; +Cc: Leo, emacs-devel
>> The attached patch does this. BTW, defining system abbrevs doesn't
>> change abbrev-changed so I leave the (let ...) out.
> The docs for my version say
> define-abbrev-table: a built-in function.
> Define TABLENAME (a symbol) as an abbrev table name.
> Define abbrevs in it according to DEFINITIONS, which is a list of
> elements
> of the form (ABBREVNAME EXPANSION HOOK USECOUNT).
> (define-abbrev-table TABLENAME DEFINITIONS)
> So, as minimum, it is not backward-compatible.
Actually, AFAIK it is backward compatible in that older versions just
ignore the tail of the list rather than checking that it's nil.
So older versions will just ignore the additional t.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-17 14:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-16 11:27 abbrev table in cperl-mode Leo
2010-04-16 19:12 ` Ilya Zakharevich
2010-04-16 20:11 ` Leo
2010-04-17 4:48 ` Ilya Zakharevich
2010-04-17 11:21 ` Leo
2010-04-17 14:42 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).