* Tab stops in perl mode broken?
@ 2003-05-20 20:12 Johnny L. Wales
0 siblings, 0 replies; 8+ messages in thread
From: Johnny L. Wales @ 2003-05-20 20:12 UTC (permalink / raw)
[root@bugzilla PhoneStats]# emacs --version
GNU Emacs 21.2.1 Copyright (C)
Ok, I have this astonishingly annoying problem in perl mode. I can't get
proper indention on some lines. Check this out:
------------
if(defined($rqpairs{'area'})) {
print "Content-type: text/html\n\n";
print "<html>";
print "<head><title>Canvassing report: $rqpairs{'area'}</title></head>\n";
print "<body bgcolor=white>";
print "Canvassing report for $rqpairs{'area'}<br>";
$dbcmd = "SELECT count(*) FROM calls WHERE ( (outgoingnum like ";
$dbcmd .= "'P1$rqpairs{'area'}%') OR (outgoingnum like 'P0";
$dbcmd .= "$rqpairs{'area'}\%')) ";
($year, $month, $day) = Date::Calc::Today();
($o_year, $o_month, $o_day) = Date::Calc::Add_Delta_Days($year, $month,
$day, -\
30);
$dstr = sprintf("'%04d-%02d-%02d' AND '%04d-%02d-%02d'",
$o_year, $o_month, $o_day, $year, $month, $day);
$dbcmd .= "AND (calldate between $dstr) ORDER BY calldate;";
$sth = $dbh -> prepare($dbcmd);
$sth->execute;
$count = $sth->fetchrow_array;
---------
Now, notice how the indention changes unexpectedly after the line
($year, $month, $day) = Date::Calc::Today();
This is also the first line where the :: notation is used. Is emacs unable
to understand this _extremely_ common notation? How can I make it
understand? (Note that vi understands just fine and will tab this file
easily.. but I think any editor that defaults to opening files read-only
is a viewer, not an editor. ;)
Further, is there some command like:
M-x when-i-say-tab-i-mean-tab-damn-it
that will make emacs ALWAYS add a tab when I hit the tab button, whether
it seems reasonable to emacs or not? I've also yet to be able to find an
easy way to set tab width without editing a configuration file..?
Any assistance would be greatly appreciated.
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.6530.1053528247.21513.help-gnu-emacs@gnu.org>]
* Re: Tab stops in perl mode broken?
[not found] <mailman.6530.1053528247.21513.help-gnu-emacs@gnu.org>
@ 2003-05-21 15:33 ` lawrence mitchell
2003-05-21 19:37 ` Edward O'Connor
1 sibling, 0 replies; 8+ messages in thread
From: lawrence mitchell @ 2003-05-21 15:33 UTC (permalink / raw)
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab stops in perl mode broken?
[not found] <mailman.6530.1053528247.21513.help-gnu-emacs@gnu.org>
2003-05-21 15:33 ` lawrence mitchell
@ 2003-05-21 19:37 ` Edward O'Connor
1 sibling, 0 replies; 8+ messages in thread
From: Edward O'Connor @ 2003-05-21 19:37 UTC (permalink / raw)
Hey Johnny.
> 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.
Well, that shouldn't be so hard to hack up. See the variable
`last-input-event'.
> 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?
I keep mine in CVS (along with the rest of my dotfiles). This seems to
be Good Enough For Me in this regard.
Ted
--
Edward O'Connor
oconnor@soe.ucsd.edu
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>]
* Re: Tab stops in perl mode broken?
[not found] <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>
@ 2003-05-20 22:38 ` lawrence mitchell
2003-05-21 14:37 ` Johnny L. Wales
2003-05-21 16:22 ` Stefan Monnier
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: lawrence mitchell @ 2003-05-20 22:38 UTC (permalink / raw)
Johnny L. Wales wrote:
[...] 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.
> Further, is there some command like:
> M-x when-i-say-tab-i-mean-tab-damn-it
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.
> that will make emacs ALWAYS add a tab when I hit the tab button, whether
> it seems reasonable to emacs or not? I've also yet to be able to find an
> easy way to set tab width without editing a configuration file..?
M-x customize-variable RET tab-stop-list RET
If you change this and then save your changes, tab-stop-list
will be set.
--
lawrence mitchell <wence@gmx.li>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab stops in perl mode broken?
2003-05-20 22:38 ` lawrence mitchell
@ 2003-05-21 14:37 ` Johnny L. Wales
0 siblings, 0 replies; 8+ messages in thread
From: Johnny L. Wales @ 2003-05-21 14:37 UTC (permalink / raw)
> [...] 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?
Why are there two perl modes? Why not just one?
Why is the broken perl mode the default? Why not make the good one the
default?
> > Further, is there some command like:
> > M-x when-i-say-tab-i-mean-tab-damn-it
>
> 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.
> > that will make emacs ALWAYS add a tab when I hit the tab button, whether
> > it seems reasonable to emacs or not? I've also yet to be able to find an
> > easy way to set tab width without editing a configuration file..?
>
> M-x customize-variable RET tab-stop-list RET
>
> 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?
--Me
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab stops in perl mode broken?
[not found] <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>
2003-05-20 22:38 ` lawrence mitchell
@ 2003-05-21 16:22 ` Stefan Monnier
2003-05-22 11:03 ` Kai Großjohann
2003-05-22 11:36 ` Oliver Scholz
3 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2003-05-21 16:22 UTC (permalink / raw)
>>>>> "Johnny" == Johnny L Wales <johnny@mail.booksys.com> writes:
> Ok, I have this astonishingly annoying problem in perl mode. I can't get
> proper indention on some lines. Check this out:
> ------------
> if(defined($rqpairs{'area'})) {
> print "Content-type: text/html\n\n";
> print "<html>";
> print "<head><title>Canvassing report: $rqpairs{'area'}</title></head>\n";
> print "<body bgcolor=white>";
> print "Canvassing report for $rqpairs{'area'}<br>";
> $dbcmd = "SELECT count(*) FROM calls WHERE ( (outgoingnum like ";
> $dbcmd .= "'P1$rqpairs{'area'}%') OR (outgoingnum like 'P0";
> $dbcmd .= "$rqpairs{'area'}\%')) ";
> ($year, $month, $day) = Date::Calc::Today();
> ($o_year, $o_month, $o_day) = Date::Calc::Add_Delta_Days($year, $month,
> $day, -\
> 30);
> $dstr = sprintf("'%04d-%02d-%02d' AND '%04d-%02d-%02d'",
> $o_year, $o_month, $o_day, $year, $month, $day);
> $dbcmd .= "AND (calldate between $dstr) ORDER BY calldate;";
> $sth = $dbh -> prepare($dbcmd);
> $sth->execute;
> $count = $sth->fetchrow_array;
> ---------
I have just tried the above with `emacs-21.3 -q --no-site-file' and couldn't
reproduce your problem. The ($o_year...) lines gets properly indented
below the previous line.
Could you show us a more complete example where the problem can be
reproduced ?
Stefan
PS: Yes, the default perl-mode is not as sophisticated as cperl-mode.
Note that the version in the Emacs repository is significantly improved
in some areas (provided you use font-lock).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab stops in perl mode broken?
[not found] <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>
2003-05-20 22:38 ` lawrence mitchell
2003-05-21 16:22 ` Stefan Monnier
@ 2003-05-22 11:03 ` Kai Großjohann
2003-05-22 11:36 ` Oliver Scholz
3 siblings, 0 replies; 8+ messages in thread
From: Kai Großjohann @ 2003-05-22 11:03 UTC (permalink / raw)
"Johnny L. Wales" <johnny@mail.booksys.com> writes:
> Further, is there some command like:
> M-x when-i-say-tab-i-mean-tab-damn-it
>
> that will make emacs ALWAYS add a tab when I hit the tab button, whether
> it seems reasonable to emacs or not? I've also yet to be able to find an
> easy way to set tab width without editing a configuration file..?
C-q TAB
--
This line is not blank.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab stops in perl mode broken?
[not found] <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>
` (2 preceding siblings ...)
2003-05-22 11:03 ` Kai Großjohann
@ 2003-05-22 11:36 ` Oliver Scholz
3 siblings, 0 replies; 8+ messages in thread
From: Oliver Scholz @ 2003-05-22 11:36 UTC (permalink / raw)
"Johnny L. Wales" <johnny@mail.booksys.com> writes:
[...]
> I've also yet to be able to find an easy way to set tab width
> without editing a configuration file..?
[...]
`M-x customize-variable RET tab-width RET'
Oliver
--
3 Prairial an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-05-22 11:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-20 20:12 Tab stops in perl mode broken? Johnny L. Wales
[not found] <mailman.6530.1053528247.21513.help-gnu-emacs@gnu.org>
2003-05-21 15:33 ` lawrence mitchell
2003-05-21 19:37 ` Edward O'Connor
[not found] <mailman.6487.1053461876.21513.help-gnu-emacs@gnu.org>
2003-05-20 22:38 ` lawrence mitchell
2003-05-21 14:37 ` Johnny L. Wales
2003-05-21 16:22 ` Stefan Monnier
2003-05-22 11:03 ` Kai Großjohann
2003-05-22 11:36 ` Oliver Scholz
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).