comp.lang.perl.misc-using_emacs_cperl-mode

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



From: James Keasley <me@privacy.net>
Subject: Re: emacs cperl-mode: indentation and so on...
Newsgroups: comp.lang.perl.misc,comp.emacs
Date: 22 Mar 2004 22:16:44 GMT

Cedros <siscus@cidddis.es> wrote:

> I'm learning perl and I want to use emacs and his cperl mode. I have
> some problems:
>
> - when I open a perl program, emacs run perl mode, not cperl. How can I
> do to have cperl as default?

Dumping the following lisp into your ~/.emacs file will tell
emacs to use Cperl-mode instead of perl-mode, and turns on a
couple of the other handy functions cperl-mode keeps up its sleeve.

;; Use Cperl-mode in preference to perl-mode (added 2003/11/27)
(defun modify-alist (alist-symbol key value &optional search-cdr)
  (let ((alist (symbol-value alist-symbol)))
    (while alist
      (if (eq (if search-cdr
		  (cdr (car alist))
		(car (car alist))) key)
	  (setcdr (car alist) value)
	(setq alist (cdr alist))))))

(modify-alist 'interpreter-mode-alist 'perl-mode 'cperl-mode t)
(modify-alist 'auto-mode-alist        'perl-mode 'cperl-mode t)

;; set cperl-mode to use electric parens and keywords
(setq cperl-electric-parens t)
(setq cperl-electric-keywords t)

> - also if I run cperl with M-x cperl-mode, I'm not able to have a decent
> indentation: if I press enter, emacs always return to first column next
> line. What are keys to have a decent indentation? (in VHDL-mode I use
> M-q but here it seems it doesn't function.

Not sure about this, it usually seems to "just work" for me, someone 
else will come along and enlighten you on this, I'm sure

===

From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: emacs cperl-mode: indentation and so on...
Newsgroups: comp.lang.perl.misc,comp.emacs
To: jamesk@homeric.co.uk
Date: Tue, 23 Mar 2004 13:41:27 GMT

>>>>> "James" == James Keasley <me@privacy.net> writes:

James> Dumping the following lisp into your ~/.emacs file will tell
James> emacs to use Cperl-mode instead of perl-mode, and turns on a
James> couple of the other handy functions cperl-mode keeps up its sleeve.

James> ;; Use Cperl-mode in preference to perl-mode (added 2003/11/27)
James> (defun modify-alist (alist-symbol key value &optional search-cdr)
James>   (let ((alist (symbol-value alist-symbol)))
James>     (while alist
James>       (if (eq (if search-cdr
James> 		  (cdr (car alist))
James> 		(car (car alist))) key)
James> 	  (setcdr (car alist) value)
James> 	(setq alist (cdr alist))))))

James> (modify-alist 'interpreter-mode-alist 'perl-mode 'cperl-mode t)
James> (modify-alist 'auto-mode-alist        'perl-mode 'cperl-mode t)

I just did this instead:

(while (let ((pm (rassoc 'perl-mode auto-mode-alist)))
  (and pm (setcdr pm 'cperl-mode))))
(while (let ((pm (rassoc 'perl-mode interpreter-mode-alist)))
  (and pm (setcdr pm 'cperl-mode))))

If I were a bear of slightly larger brain, I could probably collapse
this into a loop over the two items as well.  My emacs-lisp-fu has
atrophied since the early days when I wrote pp.el and dozens of other
Very Cool things.  My Perl-fu has taken its place in my brain.

print "Just another Perl and emacs-lisp hacker,"


===


From: Vivek Dasmohapatra <vivek@etla.org>
Subject: Re: emacs cperl-mode: indentation and so on...
Newsgroups: comp.lang.perl.misc,comp.emacs
Date: 24 Mar 2004 10:28:16 +0000

James Keasley <me@privacy.net> writes:

> Cedros <siscus@cidddis.es> wrote:

> > - when I open a perl program, emacs run perl mode, not cperl. How can I
> > do to have cperl as default?

> ;; Use Cperl-mode in preference to perl-mode (added 2003/11/27)
> (defun modify-alist (alist-symbol key value &optional search-cdr)
>   (let ((alist (symbol-value alist-symbol)))
>     (while alist
>       (if (eq (if search-cdr
> 		  (cdr (car alist))
> 		(car (car alist))) key)
> 	  (setcdr (car alist) value)
> 	(setq alist (cdr alist))))))

Since perl-mode will stomp all over cperl-mode if they are both loaded, I 
find it better to do this:

(defalias 'perl-mode 'cperl-mode)

Which has the advantage of being shorter too.

===

From: Serge Olkhowik <solo@isd.dp.ua>
Subject: Re: emacs cperl-mode: indentation and so on...
Newsgroups: comp.lang.perl.misc,comp.emacs
Date: Tue, 23 Mar 2004 11:00:58 +0200

On Mon, 22 Mar 2004 22:06:47 GMT
 Cedros  (Cedros) wrote:

 Cedros> I'm learning perl and I want to use emacs and his cperl mode. I have
 Cedros> some problems:

 Cedros> - when I open a perl program, emacs run perl mode, not cperl. How
 Cedros>   can I do to have cperl as default?

Try

(autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)

 Cedros> - also if I run cperl with M-x cperl-mode, I'm not able to have a
 Cedros>   decent indentation: if I press enter, emacs always return to
 Cedros>   first column next line. What are keys to have a decent
 Cedros>   indentation?  (in VHDL-mode I use M-q but here it seems it
 Cedros>   doesn't function.

Try to press C-c C-a and it'll autoindent after you enter ";" or just press
tab key.

===

From: Vivek Dasmohapatra <vivek@etla.org>
Subject: Re: emacs cperl-mode: indentation and so on...
Newsgroups: comp.lang.perl.misc,comp.emacs
Date: 24 Mar 2004 10:31:52 +0000

Cedros <siscus@cidddis.es> writes:

[snip]
> - also if I run cperl with M-x cperl-mode, I'm not able to have a decent
> indentation: if I press enter, emacs always return to first column next

You can use TAB manually, and/or put something like this in your .emacs:

(setq cperl-mode-hook
      (lambda ()
         (local-set-key [RET] 'reindent-then-newline-and-indent)))


===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu