|
|
How to hide comment lines?
I'd like to quickly toggle between displaying and hiding all lines in
the current buffer that start with my comment symbol (';' in this
case). How do I do this?
|
|
0
|
|
|
|
Reply
|
charlesfox357 (36)
|
5/25/2005 3:46:24 PM |
|
On 25 May 2005 08:46:24 -0700, <charlesfox357@hotmail.com> wrote:
>
> I'd like to quickly toggle between displaying and hiding all lines in
> the current buffer that start with my comment symbol (';' in this
> case). How do I do this?
Use color-theme.
The different colors make it simple to pick out desired content.
I stick
(require 'color-theme)
into default.el
and
(eval-after-load "color-theme" '(color-theme-marquardt))
in an user .emacs
--
With sufficient thrust, pigs fly fine.
|
|
0
|
|
|
|
Reply
|
GP
|
5/25/2005 4:05:38 PM
|
|
"foxx" <charlesfox357@hotmail.com> writes:
> I'd like to quickly toggle between displaying and hiding all lines in
> the current buffer that start with my comment symbol (';' in this
> case). How do I do this?
>
Have a look at the various 'folding' modes which are available. These
allow you to hide blocks of your file based on certain markes. There
is also hide-show mode, which allows you to hide blocks as well and
doesn't require special characters - a multi-line comment is
recognised as a block.
HTH
Tim
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
|
|
0
|
|
|
|
Reply
|
Tim
|
5/25/2005 10:31:01 PM
|
|
"foxx" <charlesfox357@hotmail.com> writes:
> I'd like to quickly toggle between displaying and hiding all lines in
> the current buffer that start with my comment symbol (';' in this
> case). How do I do this?
I wrote the following a few years ago for use with C++, but it should
work for any mode that defines comment syntax.
(defun overlay-comments(beg end attrs)
(save-excursion
(goto-char beg)
(let (state comment-start comment-end overlay)
(while (nth 4 (setq state
(parse-partial-sexp (point) end nil nil nil t)))
(goto-char (nth 8 state))
(setq comment-start (point))
(forward-comment 1)
(setq comment-end (point))
(while (= (char-before comment-end) ?\n)
(setq comment-end (1- comment-end)))
(setq overlay (make-overlay comment-start comment-end))
(mapc #'(lambda (attr)
(overlay-put overlay (car attr) (cdr attr)))
attrs)))))
(defun hide-comments()
(interactive)
(overlay-comments (point-min)
(point-max)
'((category . comment) (invisible . comment))))
(defun show-comments()
(interactive)
(dolist (ov (overlays-in (point-min) (point-max)))
(if (eq (overlay-get ov 'category) 'comment)
(delete-overlay ov))))
--
Jim Janney
|
|
0
|
|
|
|
Reply
|
Jim
|
6/2/2005 8:01:31 PM
|
|
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig42CDDDFF175069A3358D5982
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Jim Janney wrote:
> "foxx" <charlesfox357@hotmail.com> writes:
>
>
>>I'd like to quickly toggle between displaying and hiding all lines in
>>the current buffer that start with my comment symbol (';' in this
>>case). How do I do this?
>
>
> I wrote the following a few years ago for use with C++, but it should
> work for any mode that defines comment syntax.
>
I've just added that to my elisp includes etc. and tried it out and it's
great, but is there a way to convince it to eat comment lines in their
entirety? - I tried it out in a lisp file with a couple of lines
starting with ';' and although the comments disappear, the lines aren't
folded.
Is this possible to do?
Rupert
--------------enig42CDDDFF175069A3358D5982
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iQCVAwUBQp+OSEbXf6SW2FaGAQHULgQAt0+S8e+/nwBHtTp/d8FX5KKc4yhCQM+A
KzeQQPB9lmTmvQulI+n3+KlP73inu7rc7/6kT1lUcPpI+aVPH28PrDj6G43CQFCk
svRMWYXGiD3ZX/vX3GcYR/8gx2r7Ssjr2faqcQWTpEZSURicxn7bmQ2+3sMYhGbn
26Ms8dJdudw=
=CGMN
-----END PGP SIGNATURE-----
--------------enig42CDDDFF175069A3358D5982--
|
|
0
|
|
|
|
Reply
|
Rupert
|
6/2/2005 10:55:03 PM
|
|
Rupert Swarbrick <rupert.swarbrick@lineone.net> writes:
> Jim Janney wrote:
> > "foxx" <charlesfox357@hotmail.com> writes:
> >
> >
> >>I'd like to quickly toggle between displaying and hiding all lines in
> >>the current buffer that start with my comment symbol (';' in this
> >>case). How do I do this?
> >
> >
> > I wrote the following a few years ago for use with C++, but it should
> > work for any mode that defines comment syntax.
> >
> I've just added that to my elisp includes etc. and tried it out and it's
> great, but is there a way to convince it to eat comment lines in their
> entirety? - I tried it out in a lisp file with a couple of lines
> starting with ';' and although the comments disappear, the lines aren't
> folded.
>
> Is this possible to do?
Removing the lines
(while (= (char-before comment-end) ?\n)
(setq comment-end (1- comment-end)))
in overlay-comments seems to have that effect. It's been long enough
since I wrote this that I don't remember exactly how it works.
--
Jim Janney
|
|
0
|
|
|
|
Reply
|
Jim
|
6/3/2005 6:55:11 PM
|
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jim Janney wrote:
|
| Removing the lines
|
| (while (= (char-before comment-end) ?\n)
| (setq comment-end (1- comment-end)))
|
| in overlay-comments seems to have that effect. It's been long enough
| since I wrote this that I don't remember exactly how it works.
|
Finally gotten round to testing it and it works fabulously. Thanks!
Rupert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iQCVAwUBQqNwm0bXf6SW2FaGAQLA1AQAn8i01JZwMwsrta1RoKK33pWc3dtraVAQ
u7do0sw7uEQs9S7NaevB9xuYV6nriKZXd7HNStmLTTrBSKL10lTIL0WNcGQSHTRG
GaULl6W7S4vs5K1wFHbo/K+z4RVSRYo6YlPK3RN2r/2Hs4dr396ZB5ijMYryXsH6
RgMltl7MWdU=
=b/yK
-----END PGP SIGNATURE-----
|
|
0
|
|
|
|
Reply
|
Rupert
|
6/5/2005 9:37:32 PM
|
|
Thanks a lot for the code -- that just what I wanted.
just one problem though, when I do it on somethign like this:
(defun myfun ()
(for (a '(1 2 3))
;here is a comment
(print a)
(print "hello")))
it messes up some of the indentation like this:
(defun myfun ()
(for (a '(1 2 3))
(print a) <---line after comment is too
indented
(print "hello")))
any idea whats going on? (Thats with those 2 lines removed as
discussed in previous posts)
|
|
0
|
|
|
|
Reply
|
foxx
|
6/8/2005 2:38:38 PM
|
|
|
7 Replies
440 Views
(page loaded in 0.111 seconds)
Similiar Articles: how to comment out multiple lines in kshell? - comp.unix ...How to hide comment lines? - comp.emacs... except I don't see the word "Done" in the label.>> If I comment out the lines ... ... Comment on Parsing Multiple Lines. Pdf modify: how to cover/hide relevant info? - comp.text.pdf ...How to hide comment lines? - comp.emacs Pdf modify: how to cover/hide relevant info? - comp.text.pdf ... To "flatten" this comment (make it a plain vanilla graphic in the ... Parsing multiple lines with regex - comp.lang.java.programmer ...How to hide comment lines? - comp.emacs Parsing multiple lines with regex - comp.lang.java.programmer ... Comment on Parsing Multiple Lines. Select or Download Code; Re ... Crystal reports - hiding line object - comp.database.oracle ...Hi, how to hide a line object in CR? thank you in advance, ziggy ... How to center a prompt box?? - comp.lang.javascript... an example of what you are trying to do, some comments ... visibility: > hidden; TOP: 496px"> If you hide the ... a manufacturer of electrical equipment, has a line of ... How to filter out lines? - comp.lang.awkhow to comment out multiple lines in kshell? - comp.unix ... I can do # to do one line at a time. How do I bulk comment out many lines? like you can in other languages? ... how to merge multiple lines into one line - comp.lang.awk ...how to comment out multiple lines in kshell? - comp.unix ... Search in *.rex files - comp.lang.rexx how to merge multiple lines into one line - comp.lang.awk ... Could anyone give me the spice-mode.el - comp.emacsHi, All I am new to *NIX and I am thinking of writing spice code under Emacs. However, I have no idea of Emacs Lisp. Hence, I could not write a packa... sed: how to remove all duplicated white lines? - comp.unix.shell ...How can I remove duplicate polygons? - comp.graphics.apps ... sed: how to remove all duplicated white lines? - comp.unix.shell ... Sed comments are lines where the first ... how to pass command line arguments to makefile - comp.unix ...... execute a command in a makefile that has to take arguments > from the command line ... there is no man documentation for docmd > Please do not cut out the poster's comments ... How to Hide Tan Lines | eHow.comTaaz: How To Hide A Tan Line; Beauty Hill: How to Get Rid of Tan Lines; Photo Credit ... Comments You May Also Like. How to Tan Deer Hide the Old Way. Brain tanning is the ... VI Editor: A mtehod to hide comment lines: vi, lines, comment ...In the LINUX VI editor, is there a way to view a text file and hide all comment lines (lines that begin with # ) so that you only see operational lines? 7/21/2012 12:21:32 AM
|
|
|
|
|
|
|
|
|