all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Property for treating a string as a single character when deleting
@ 2014-08-11 15:02 Tom
  2014-08-12  2:16 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Tom @ 2014-08-11 15:02 UTC (permalink / raw)
  To: help-gnu-emacs

Is there a property or some other way to treat a string 
as a single character? I know I can add the intangible
property and then cursor movements jumps over the string
like its a single character. Is there a property for 
making the string behave like this for deletion too?
So, for example, when I backspace at the rightmost 
character of the string then the whole string is deleted
at once like it's a single character.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Property for treating a string as a single character when deleting
       [not found] <mailman.6973.1407769404.1147.help-gnu-emacs@gnu.org>
@ 2014-08-11 21:29 ` Emanuel Berg
  2014-08-12  3:33 ` Pascal J. Bourguignon
  1 sibling, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2014-08-11 21:29 UTC (permalink / raw)
  To: help-gnu-emacs

Tom <adatgyujto@gmail.com> writes:

> Is there a property or some other way to treat a
> string as a single character? I know I can add the
> intangible property and then cursor movements jumps
> over the string like its a single character. Is there
> a property for making the string behave like this for
> deletion too? So, for example, when I backspace at
> the rightmost character of the string then the whole
> string is deleted at once like it's a single
> character.

You mean like `backward-kill-word', which I have (and
probably you to) at M-DEL - do you want this encoded in
the text so that you don't have to hit Meta, just DEL?
Is that really worth doing? And for what mode? If this
is what you want to do, and you really want it, I think
you would have to locally rebind the DEL key to a
defun; the defun will then do `backward-word', then
`thing-at-point' (or some other combo to that extent),
then examine the properties, and determine if your
special mark is there, if so, the whole thing would be
deleted, if not, the DEL would just do
delete-backward-char as usual. Or, if you don't insist
on the "property method", you could have DEL react to
the char to be deleted - if it is a string delimiter,
search for the corresponding delimiter - if there is a
hit, ... and so on. This all seem like a lot of work
for a really slim gain - and I'm not even sure there is
a gain, because perhaps you'll start "deleting" other
things that way, and expect the whole thing to be
killed, only it won't. I can only speak (for) my mind,
and that would be confused by this. M-DEL is such a
close and comfortable and ingrained way - why not just
use it?

-- 
underground experts united


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Property for treating a string as a single character when deleting
  2014-08-11 15:02 Tom
@ 2014-08-12  2:16 ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-08-12  2:16 UTC (permalink / raw)
  To: help-gnu-emacs

> Is there a property or some other way to treat a string 
> as a single character?

You can make the string be a single char, with a `display' property that
makes it display as something else.


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Property for treating a string as a single character when deleting
       [not found] <mailman.6973.1407769404.1147.help-gnu-emacs@gnu.org>
  2014-08-11 21:29 ` Property for treating a string as a single character when deleting Emanuel Berg
@ 2014-08-12  3:33 ` Pascal J. Bourguignon
  1 sibling, 0 replies; 4+ messages in thread
From: Pascal J. Bourguignon @ 2014-08-12  3:33 UTC (permalink / raw)
  To: help-gnu-emacs

Tom <adatgyujto@gmail.com> writes:

> Is there a property or some other way to treat a string 
> as a single character? I know I can add the intangible
> property and then cursor movements jumps over the string
> like its a single character. Is there a property for 
> making the string behave like this for deletion too?
> So, for example, when I backspace at the rightmost 
> character of the string then the whole string is deleted
> at once like it's a single character.

It would depend on what your "string" is.

If it's a syntactic string like in programming languages, that is
quoted, eg. "this is a string", then you can use the sexp commands.
forward-sexp, backward-sexp, kill-sexp, etc. But this works only in
those programming language modes. text-mode doesn't recognize them as
sexps. (forward-sexp skips words, not quoted strings).

If it's a "word", as defined by the current mode, then you can use the
word commands, forward-word, backward-word, kill-word, etc.

It may also be a "paragraph", and the you can use forward-paragraph,
backward-paragraph, kill-paragraph, etc.

C-f   C-b   C-d   DEL   character
M-f   M-b   M-d   M-DEL word
C-M-f C-M-b C-M-d       sexp
M-}   M-{               paragraph

If you can come with a definition for your strings, then you can write
commands like those, to skip over those strings and manipulate them
(delete, select, etc).  If your definition is close to that of word,
sexp or paragraph, you may be able to make a derivate of your mode,
tuning its understanding of those concepts. (Words are defined by the
syntax table of the mode). 


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-12  3:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6973.1407769404.1147.help-gnu-emacs@gnu.org>
2014-08-11 21:29 ` Property for treating a string as a single character when deleting Emanuel Berg
2014-08-12  3:33 ` Pascal J. Bourguignon
2014-08-11 15:02 Tom
2014-08-12  2:16 ` Stefan Monnier

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.