* How to really escape a double quote?
@ 2011-02-24 23:54 MarkS.
2011-02-25 0:00 ` David Kastrup
0 siblings, 1 reply; 8+ messages in thread
From: MarkS. @ 2011-02-24 23:54 UTC (permalink / raw)
To: help-gnu-emacs
This is a two part question, but both parts are looking for how to
escape a double quote AND have it work with Emacs.
I was looking for a way to make Emacs delete inside of delimiters the
way Vim does. I found some code that some nice person had written. The
key search line is like:
(skip-chars-backward "^(<[“") (setq p1 (point))
but there's no double quote, which is what I need most often. I looked
up Emacs/lisp documentation on-line, and it said that I could escape a
double-quote with a slash. So I tried changing the line to:
(skip-chars-backward "\"^(<[“") (setq p1 (point))
But when I run the code, it can't find the escaped double quote. It
seems to ignore it.
So, how do I get code like this to recognize an escaped quote mark?
The other part of the question is, how do I get a key mapping that
uses double quotes?
I tried
(global-set-key "\c-x\"" 'delete-stuff)
but this gave me all sorts of errors. However, if I activate global-
set-key interactively, I can set control-x " and it works to activate
the function. So there must be some way to make emacs recognize double
quotes in a key-mapping.
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
2011-02-24 23:54 How to really escape a double quote? MarkS.
@ 2011-02-25 0:00 ` David Kastrup
2011-02-25 0:05 ` MarkS.
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: David Kastrup @ 2011-02-25 0:00 UTC (permalink / raw)
To: help-gnu-emacs
"MarkS." <throaway@yahoo.com> writes:
> This is a two part question, but both parts are looking for how to
> escape a double quote AND have it work with Emacs.
>
> I was looking for a way to make Emacs delete inside of delimiters the
> way Vim does. I found some code that some nice person had written. The
> key search line is like:
>
> (skip-chars-backward "^(<[“") (setq p1 (point))
>
> but there's no double quote, which is what I need most often. I looked
> up Emacs/lisp documentation on-line, and it said that I could escape a
> double-quote with a slash. So I tried changing the line to:
>
> (skip-chars-backward "\"^(<[“") (setq p1 (point))
^ loses its special meaning if it is not the first character of the
string. So move your escaped double-quote one position to the right.
--
David Kastrup
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
2011-02-25 0:00 ` David Kastrup
@ 2011-02-25 0:05 ` MarkS.
2011-02-26 2:05 ` Le Wang
[not found] ` <mailman.0.1298685964.28733.help-gnu-emacs@gnu.org>
2011-02-26 8:55 ` Kevin Rodgers
[not found] ` <mailman.18.1298710549.28733.help-gnu-emacs@gnu.org>
2 siblings, 2 replies; 8+ messages in thread
From: MarkS. @ 2011-02-25 0:05 UTC (permalink / raw)
To: help-gnu-emacs
On Feb 24, 4:00 pm, David Kastrup <d...@gnu.org> wrote:
> ^ loses its special meaning if it is not the first character of the
> string. So move your escaped double-quote one position to the right.
>
> --
> David Kastrup
Thank you! I didn't realize there was a special meaning to the caret
in this context. Now just need to figure out how to get the global key
definition to work.
Thanks again!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
2011-02-25 0:05 ` MarkS.
@ 2011-02-26 2:05 ` Le Wang
[not found] ` <mailman.0.1298685964.28733.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Le Wang @ 2011-02-26 2:05 UTC (permalink / raw)
To: MarkS.; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 353 bytes --]
> Thank you! I didn't realize there was a special meaning to the caret
> in this context. Now just need to figure out how to get the global key
> definition to work.
>
> Thanks again!
>
The vector representation of key sequence always seems to much cleaner to
me. Does this do what you want?
(global-set-key [(control x) (\")] 'delete-stuff)
--
Le
[-- Attachment #2: Type: text/html, Size: 710 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
[not found] ` <mailman.0.1298685964.28733.help-gnu-emacs@gnu.org>
@ 2011-02-26 4:04 ` MarkS.
2011-02-26 5:10 ` Le Wang
0 siblings, 1 reply; 8+ messages in thread
From: MarkS. @ 2011-02-26 4:04 UTC (permalink / raw)
To: help-gnu-emacs
On Feb 25, 6:05 pm, Le Wang <l26w...@gmail.com> wrote:
Yes! Thank you! That was the ticket. I suppose there's a page out
there that talks about vector representations? I'm still working
mainly out of a book.
Thanks again!
Mark
> > Thank you! I didn't realize there was a special meaning to the caret
> > in this context. Now just need to figure out how to get the global key
> > definition to work.
>
> > Thanks again!
>
> The vector representation of key sequence always seems to much cleaner to
> me. Does this do what you want?
>
> (global-set-key [(control x) (\")] 'delete-stuff)
>
> --
> Le
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
2011-02-26 4:04 ` MarkS.
@ 2011-02-26 5:10 ` Le Wang
0 siblings, 0 replies; 8+ messages in thread
From: Le Wang @ 2011-02-26 5:10 UTC (permalink / raw)
To: MarkS.; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]
On Sat, Feb 26, 2011 at 12:04 PM, MarkS. <throaway@yahoo.com> wrote:
> On Feb 25, 6:05 pm, Le Wang <l26w...@gmail.com> wrote:
> Yes! Thank you! That was the ticket. I suppose there's a page out
> there that talks about vector representations? I'm still working
> mainly out of a book.
>
>
Okay, you can look at the GNU Emacs manual section for the "kbd" macro.
This way looks fairly straight forward.
http://www.gnu.org/s/emacs/manual/html_node/elisp/Key-Sequences.html#Key-Sequences
I can't find the vector notation clearly discussed in the GNU Emacs manual.
I know it from XEmacs and just always preferred it. As far as I can tell,
it works the same in GNU Emacs.
You can read more about key sequence vectors in the XEmacs manual:
http://www.gnu.org/s/emacs/manual/html_node/elisp/Key-Sequences.html#Key-Sequences
A note about your original question, the "^" prefix to skip-chars-backward
is discusses in the doc string (well it links to skip-chars-forward, and
discusses it there). The doc string of functions and variables is a great
way to explore Emacs.
--
Le
[-- Attachment #2: Type: text/html, Size: 1764 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
2011-02-25 0:00 ` David Kastrup
2011-02-25 0:05 ` MarkS.
@ 2011-02-26 8:55 ` Kevin Rodgers
[not found] ` <mailman.18.1298710549.28733.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2011-02-26 8:55 UTC (permalink / raw)
To: help-gnu-emacs
On 2/24/11 5:00 PM, David Kastrup wrote:
...
> ^ loses its special meaning if it is not the first character of the
> string. So move your escaped double-quote one position to the right.
I didn't know that! Here's the reference from (elisp)Regexp Special:
For historical compatibility reasons, `^' can be used only at the
beginning of the regular expression, or after `\(', `\(?:' or `\|'.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to really escape a double quote?
[not found] ` <mailman.18.1298710549.28733.help-gnu-emacs@gnu.org>
@ 2011-02-26 9:00 ` David Kastrup
0 siblings, 0 replies; 8+ messages in thread
From: David Kastrup @ 2011-02-26 9:00 UTC (permalink / raw)
To: help-gnu-emacs
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> On 2/24/11 5:00 PM, David Kastrup wrote:
> ...
>> ^ loses its special meaning if it is not the first character of the
>> string. So move your escaped double-quote one position to the right.
>
> I didn't know that! Here's the reference from (elisp)Regexp Special:
>
> For historical compatibility reasons, `^' can be used only at the
> beginning of the regular expression, or after `\(', `\(?:' or
> `\|'.
You are looking in a non-obvious place for information which you then
somehow map to the required one, making it appear like using Emacs is a
black art. It would suffice to consult the DOC string of the function
in question:
skip-chars-forward is a built-in function in `C source code'.
(skip-chars-forward STRING &optional LIM)
Move point forward, stopping before a char not in STRING, or at pos LIM.
STRING is like the inside of a `[...]' in a regular expression
except that `]' is never special and `\' quotes `^', `-' or `\'
(but not at the end of a range; quoting is never needed there).
Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
With arg "^a-zA-Z", skips nonletters stopping before first letter.
Char classes, e.g. `[:alpha:]', are supported.
Returns the distance traveled, either zero or positive.
[back]
--
David Kastrup
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-02-26 9:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-24 23:54 How to really escape a double quote? MarkS.
2011-02-25 0:00 ` David Kastrup
2011-02-25 0:05 ` MarkS.
2011-02-26 2:05 ` Le Wang
[not found] ` <mailman.0.1298685964.28733.help-gnu-emacs@gnu.org>
2011-02-26 4:04 ` MarkS.
2011-02-26 5:10 ` Le Wang
2011-02-26 8:55 ` Kevin Rodgers
[not found] ` <mailman.18.1298710549.28733.help-gnu-emacs@gnu.org>
2011-02-26 9:00 ` David Kastrup
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).