help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tab stops in perl mode broken?


From: lawrence mitchell
Subject: Re: Tab stops in perl mode broken?
Date: Wed, 21 May 2003 16:33:43 +0100
User-agent: Gnus/5.090011 (Oort Gnus v0.11) Emacs/20.4 (sparc-sun-solaris2.6)

Johnny L. Wales wrote:
> Me:
>> [...] Emacs' default perl-mode and indentation problems

>> Try using cperl-mode, rather than perl-mode.  It's a much
>> improved perl mode.  It certainly handles the case you mention
>> fine in my emacs version.

> How do I set that mode?

The easiest way is to add (defalias 'perl-mode 'cperl-mode) to
your ~/.emacs.  The, any subsequent attempts to turn on
perl-mode, will use cperl-mode instead.

> Why are there two perl modes? Why not just one?

cperl-mode was originally an extra package not integrated into
Emacs.  I'm not sure why it isn't the default now that it is
there.

>> You can always to C-q TAB to insert a literal tab.  Depending on
>> programming modes, you have to find the relevant variable to get
>> them not to do syntax-driven indentaton.

> Well, what I'd actually like from an editor would be partial
> syntax-driven inedentation. That is, hitting tab once puts the
> tabs where emacs thinks they outght to be, and subsequent tab
> requests bump everything over one tab. I'd also love it if
> there was *never* a time when I hit a button and nothing
> happens.

(defun my-tab (&rest args)
  "If `last-command' was `my-tab', insert a literal tab.
Else call `indent-according-to-mode'"
  (interactive "P")
  (if (eq last-command 'my-tab)
      (save-excursion (beginning-of-line) (insert ?\t)) ; tab
      (indent-according-to-mode)))

You might need to alter this somewhat to deal with indenting
blocks.  Add this to your ~/.emacs, then, you can bind it in the
various modes you use.  E.g., for cperl-mode, you'd do:
(add-hook 'cperl-mode-hook
          #'(lambda ()
              (define-key cperl-mode-map (kbd "TAB") #'my-tab))

Note that you need to define the key after loading cperl-mode,
otherwise your binding will be overriden by cperl's default one.

[...]

>> If you change this and then save your changes, tab-stop-list
>> will be set.

> And I'll have to do this on every host, right? There's no way to have a
> single emacs config file to serve a whole network?

Depends on how you can access the files on the network.
Typically your ~/.emasc resides in your home directory.  If this
isn't the same across the network, you'd have to copy the file
around to all the hosts.  Or, and this gets slightly
complicated, write one complete .emacs, store it somewhere that's
accessible by (say) ftp, then, on each individual host, have a
minimal .emacs that `load's said file.  Emacs has builtin support
for accessing ftp files.  Look for documentation on ange-ftp for
how to use it.

Hope that sort of helps.

-- 
lawrence mitchell <wence@gmx.li>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]