Re: [Golfing] Uncommenting a block
by moritz (Cardinal) on Apr 14, 2010 at 12:33 UTC
|
With vim it's easy to insert blocks of text, I usually comment out stuff with a # and then a blank.
You can mark the block with Ctrl+v, then go to the first column, type I#<blank><escape> and be happy. Deleting is just as easy: again mark with Ctrl+v, and delete with d (or x, for that matter). | [reply] [d/l] [select] |
|
Well it wasn't an editor question ...¹
In this use case I had to comment out org-mode syntax which only works at the beginning of the line and unfortunately doesn't tolerate any leading "#" ...
(1)comment-region in emacs is even easier, I bound a macro to a key which (un)comments the marked region or the current line, chunks, paragraphs or function depending on repetition! And if I miss a vi-feature I switch to viper-mode ...
| [reply] [d/l] |
|
Well it wasn't an editor question ...
Which can still be answered by "use the appropriate tool for the job", which in this case happens to be an editor.
Abusing language features is an ugly hack, and going to hurt you in the long run. One drawback of using a heredoc is that you don't see if you're inside a comment without knowing the context.
Not seeing the context happens quite often, for example when reviewing diffs/patches.
Perl 6 - links to (nearly) everything that is Perl 6.
| [reply] |
|
Re: [Golfing] Uncommenting a block
by stefbv (Curate) on Apr 14, 2010 at 17:05 UTC
|
So you want to embed TODO headlines in perl code, than use the global
TODO list from agenda views to see what needs to be done further in
your code, right? If yes, than it's an interesting approach, which
certainly has it's advantages.
For this task, I use a (classic) remember TODO template to create new headlines in specific org files. This template will automatically add a link to the line of the code in the buffer was called from.
Cheers, Stefan
| [reply] |
|
> So you want to embed TODO headlines in perl code, than use the global TODO list from agenda views to see what needs to be done further in your code, right?
yes kind of, many features of org-mode are very intuitive.
For the records, the best solution I found so far is
print;
=org
* TODO whatever ...
**
=cut
print;
this is legal Perl code (but not legal POD because of missing blank lines and unknown directive)
or
sub ORG ($) {
}
print;
ORG <<'';
* TODO whatever ...
**
print;
UPDATE: repaired code, haven't taught my Wiki-expander to igore code tags yet... | [reply] [d/l] [select] |
|
print;
=for org
* TODO whatever ...
**
=cut
print;
Stefan
Update: added spaces before and after POD.
Update2: s/spaces/empty lines/ | [reply] [d/l] |
Re: [Golfing] Uncommenting a block
by Anonymous Monk on Apr 14, 2010 at 12:03 UTC
|
| [reply] |
|
if ($habibi) {
print $habibi;
<<'' if (0); #forget the following
print " talks often much cr*p";<P>
$h++
}
Warning about whitespaces in "empty" lines ending a heredoc seem to be a good application for code filters.
(...finally)
| [reply] [d/l] |
|
| [reply] [d/l] |
|
|
Re: [Golfing] Uncommenting a block
by ikegami (Patriarch) on Apr 15, 2010 at 16:01 UTC
|
I hate that your method ends with a blank line. Too inconspicuous.
if(0){q{
...
}}
0&&q{
...
}
if(0){ } is great for temporary debugging code too. You can just toggle between 0 and 1.
| [reply] [d/l] [select] |
|
> Too inconspicuous.
in the context of emacs it's ok ¹ , but yes other editors might be in danger...
I could cite Moritz: "use the right tools!" ;-)
¹)
- org-mode is an emacs-feature
- emacs visualizes trailing whitespaces
- cperl-mode would instantly highlight an falsely extended here-doc
- fly-make would complain about broken syntax
| [reply] |
|
| [reply] |
|