help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Property for treating a string as a single character when deleting


From: Pascal J. Bourguignon
Subject: Re: Property for treating a string as a single character when deleting
Date: Tue, 12 Aug 2014 05:33:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Tom <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]