Subject: Re: bug#10934: 24.0.94; cperl system abbrevs fix

From: Stefan Monnier <[email-masked]>
Date: Sun, 04 Mar 2012 09:48:42 -0500

> In cperl-mode it uses a hack to avoid having programmably-defined
> abbrevs written to the abbrev file. This is not safe i.e. those abbrevs
> can still be saved to disk, and users might be tricked to edit them but
> lose their editing because they are redefined by cperl-mode.

> I think the following patch is due.

Thanks for the patch.
But cperl-mode maintainership is a bit delicate, so I prefer to minimize the
difference between our version and the upstream version.
IOW, please try and find a patch that is acceptable to Ilya (I suspect
that he'll want the patch to be backward-compatible).

        Stefan

PS: The whole define-abbrev-table (c|sh)ould be moved to the toplevel.

> commit 0d5a31c8fc9faf708e98bee32913bc2dfe31bf7d
> Date:   Fri Apr 16 21:09:01 2010 +0100

>     Fix cperl-mode abbrevs
    
>     See http://permalink.gmane.org/gmane.emacs.devel/123752.
> ---
>  lisp/progmodes/cperl-mode.el |   44 ++++++++++++++++++++----------------------
>  1 file changed, 21 insertions(+), 23 deletions(-)

> 	Modified lisp/progmodes/cperl-mode.el
> diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
> index eb881d01..3a332b24 100644
> --- a/lisp/progmodes/cperl-mode.el
> +++ b/lisp/progmodes/cperl-mode.el
> @@ -1714,29 +1714,27 @@ (defun cperl-mode ()
>  			  [(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))