* How to show all characters in a specific line
@ 2014-12-31 21:16 Harry Putnam
2014-12-31 22:09 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Harry Putnam @ 2014-12-31 21:16 UTC (permalink / raw)
To: help-gnu-emacs
How to show all characters such as \t and any others, printable or
not.
What I'm after specifically is to find a piece of code I once snagged
probably here... long ago.
It worked like the :l (:el) command in vim
In vi/vim on any line and in Command mode if you press :l <RET> you will
see any \t, newline and etc.
Great for conf files that require tabs between elements or anywhere
you don't want space before the newline.
Someone helped me write that or at least edit existing code to suite.
Can anyone point me in the right direction... perhaps there are
existing emacs commands that do the same thing?
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: How to show all characters in a specific line
2014-12-31 21:16 How to show all characters in a specific line Harry Putnam
@ 2014-12-31 22:09 ` Drew Adams
2015-01-01 1:46 ` Harry Putnam
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-12-31 22:09 UTC (permalink / raw)
To: Harry Putnam, help-gnu-emacs
> In vi/vim on any line and in Command mode if you press :l <RET> you
> will see any \t, newline and etc.
If you are talking only about whitespace chars then you can use
`whitespace-mode' to show them highlighted in various ways or
contexts. See the Emacs manual, node `Useless Whitespace' for more
information.
You can also use library `highlight-chars.el' to do this. It lets you
highlight any characters pretty much any way you like. It is available
from MELPA or Emacs Wiki (the wiki is down at the moment, however).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to show all characters in a specific line
2014-12-31 22:09 ` Drew Adams
@ 2015-01-01 1:46 ` Harry Putnam
2015-01-01 3:17 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Harry Putnam @ 2015-01-01 1:46 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
>> In vi/vim on any line and in Command mode if you press :l <RET> you
>> will see any \t, newline and etc.
>
> If you are talking only about whitespace chars then you can use
> `whitespace-mode' to show them highlighted in various ways or
> contexts. See the Emacs manual, node `Useless Whitespace' for more
> information.
>
> You can also use library `highlight-chars.el' to do this. It lets you
> highlight any characters pretty much any way you like. It is available
> from MELPA or Emacs Wiki (the wiki is down at the moment, however).
Thanks for the good useful input.
`whitespace-mode' seems to do all I wanted and compared to
`highlight-chars', it is much more readable since it doesn't just put a
fairly opaque blob of color where a tab is used.
(I realize the face is customizable... but by default its fairly blotto
looking to read)
`whitespace-mode' puts an icon of sorts: >> but smaller, for tab and
. for space. All on a background color of a medium dark grey.
Mush easier on the eyes and easier to ascertain immediately what has
been put down.
But still (And no religious scrap intended) neither of those is really
as readable and handy as vim's :l Which puts only an icon in the
place of \t (^I). It collapses the whitespace and puts a series of ^I
for however many \t were used.
I don't think a snippet of whitespace-mode or hightlight-chars will
survive mail incoding without creating some kind of image of it, but
the vim look is just common keyboard characters with no higlight:
This:
rsync_short_args -avlR
rsync_long_args --stats --delete --numeric-ids --delete-excluded
Becomes:
rsync_short_args^I-avlR$
rsync_long_args^I--stats^I--delete^I--numeric-ids^I--delete-excluded$
Plus by default it does not process the whole buffer. Just the current
line or more if selected.
Its just the rest of vim is not my favorite; so whitespace-mode looks
like the winner.
Thanks again
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: How to show all characters in a specific line
2015-01-01 1:46 ` Harry Putnam
@ 2015-01-01 3:17 ` Drew Adams
2015-01-04 13:19 ` Harry Putnam
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2015-01-01 3:17 UTC (permalink / raw)
To: Harry Putnam, help-gnu-emacs
> `whitespace-mode' seems to do all I wanted and compared to
> `highlight-chars', it is much more readable since it doesn't just
> put a fairly opaque blob of color where a tab is used.
>
> (I realize the face is customizable... but by default its fairly
> blotto looking to read)
The default color for the TAB-highlighting face is a pale yellow
or off-white background (`LemonChiffon').
> `whitespace-mode' puts an icon of sorts: >> but smaller, for tab and
> . for space. All on a background color of a medium dark grey.
>
> Mush easier on the eyes and easier to ascertain immediately what has
> been put down.
>
> But still (And no religious scrap intended) neither of those is
> really as readable and handy as vim's :l Which puts only an icon
> in the place of \t (^I). It collapses the whitespace and puts a
> series of ^I for however many \t were used.
To get that effect, all you need to do is to tell Emacs to treat
TAB the same way it treats other control characters (except newline):
(aset (window-display-table) 9
(vector (make-glyph-code ?^ 'escape-glyph)
(make-glyph-code (+ 9 64) 'escape-glyph)))
You can use whatever display table you like in place of
`(window-display-table)' - for example, you can create your own
or you can change `standard-display-table'.
That code is taken from the Elisp manual, node `Display Tables'.
9 is the value of a TAB character (`C-i').
> I don't think a snippet of whitespace-mode or hightlight-chars will
> survive mail incoding without creating some kind of image of it, but
> the vim look is just common keyboard characters with no higlight:
>
> This:
> rsync_short_args -avlR
> rsync_long_args --stats --delete --numeric-ids --delete-
> excluded
>
> Becomes:
> rsync_short_args^I-avlR$
> rsync_long_args^I--stats^I--delete^I--numeric-ids^I--delete-
> excluded$
See above. That is how Emacs treats control characters generally,
except for newline and TAB, provided your option `ctl-arrow' is
non-nil.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to show all characters in a specific line
2015-01-01 3:17 ` Drew Adams
@ 2015-01-04 13:19 ` Harry Putnam
0 siblings, 0 replies; 5+ messages in thread
From: Harry Putnam @ 2015-01-04 13:19 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
[...]
>> But still (And no religious scrap intended) neither of those is
>> really as readable and handy as vim's :l Which puts only an icon
>> in the place of \t (^I). It collapses the whitespace and puts a
>> series of ^I for however many \t were used.
>
> To get that effect, all you need to do is to tell Emacs to treat
> TAB the same way it treats other control characters (except newline):
>
> (aset (window-display-table) 9
> (vector (make-glyph-code ?^ 'escape-glyph)
> (make-glyph-code (+ 9 64) 'escape-glyph)))
>
Thanks for the helpful input and taking the time to walk me thru a
bit.
[...]
Looking for something else I stumbled upon the code snippet I thought
i'd lost:
Its pretty week, I guess, since it only covers 2 things:
(defun vi-list ()
"Simulate a :set list in Vi."
(interactive)
(standard-display-ascii ?\t "^I")
(standard-display-ascii ?\n "$\n")
)
(defun vi-nolist ()
"Simulate a :set nolist in Vi."
(interactive)
(standard-display-ascii ?\t "\t")
(standard-display-ascii ?\n "\n")
)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-04 13:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31 21:16 How to show all characters in a specific line Harry Putnam
2014-12-31 22:09 ` Drew Adams
2015-01-01 1:46 ` Harry Putnam
2015-01-01 3:17 ` Drew Adams
2015-01-04 13:19 ` Harry Putnam
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.