* word delimiter
@ 2003-03-04 18:34 Peter Lee
2003-03-04 19:18 ` Jesper Harder
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peter Lee @ 2003-03-04 18:34 UTC (permalink / raw)
Can someone tell me where (or if) I can configure word delimiters?
Currently forward/backward-word stops on underscores for me. ie
m_nCount.
I'd like it to consider m_nVar one word and not two.
TIA.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: word delimiter
2003-03-04 18:34 word delimiter Peter Lee
@ 2003-03-04 19:18 ` Jesper Harder
2003-03-04 19:46 ` Kevin Rodgers
2003-03-04 22:14 ` kgold
2 siblings, 0 replies; 6+ messages in thread
From: Jesper Harder @ 2003-03-04 19:18 UTC (permalink / raw)
Peter Lee <spam@nospam.org> writes:
> Can someone tell me where (or if) I can configure word delimiters?
> Currently forward/backward-word stops on underscores for me. ie
> m_nCount.
Change the entry for '_' in the syntax table for the appropriate mode.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: word delimiter
2003-03-04 18:34 word delimiter Peter Lee
2003-03-04 19:18 ` Jesper Harder
@ 2003-03-04 19:46 ` Kevin Rodgers
2003-03-04 22:14 ` kgold
2 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2003-03-04 19:46 UTC (permalink / raw)
Peter Lee wrote:
> Can someone tell me where (or if) I can configure word delimiters?
> Currently forward/backward-word stops on underscores for me. ie
> m_nCount.
Use forward/backward-sexp (C-M-f and C-M-b) instead.
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: word delimiter
2003-03-04 18:34 word delimiter Peter Lee
2003-03-04 19:18 ` Jesper Harder
2003-03-04 19:46 ` Kevin Rodgers
@ 2003-03-04 22:14 ` kgold
2003-03-05 2:01 ` Sandip Chitale
2 siblings, 1 reply; 6+ messages in thread
From: kgold @ 2003-03-04 22:14 UTC (permalink / raw)
Sample .emacs code for C, C++, Java:
(add-hook 'c-mode-common-hook
(function (lambda ()
(modify-syntax-entry ?_ "w" c++-mode-syntax-table)
(modify-syntax-entry ?_ "w" c-mode-syntax-table)
(modify-syntax-entry ?_ "w" java-mode-syntax-table)
)))
Peter Lee <spam@nospam.org> writes:
> Can someone tell me where (or if) I can configure word delimiters?
> Currently forward/backward-word stops on underscores for me. ie
> m_nCount.
--
--
Ken Goldman kgold@watson.ibm.com 914-784-7646
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: word delimiter
2003-03-04 22:14 ` kgold
@ 2003-03-05 2:01 ` Sandip Chitale
2003-03-05 7:27 ` Sandip Chitale
0 siblings, 1 reply; 6+ messages in thread
From: Sandip Chitale @ 2003-03-05 2:01 UTC (permalink / raw)
I see that people are suggesting modifying the syntax of '_' to word.
It is related to the discussion if following thread:
http://groups.google.com/groups?dq=&hl=en&lr=lang_en&ie=UTF-8&threadm=84bs0wpiim.fsf%40lucy.is.informatik.uni-duisburg.de&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26group%3Dgnu.emacs.help%26start%3D25
Someone else suggested that modifying the syntax may be too drastic
because
it will affect other commands. Instead you should define new defuns
which
do the work.
Here is some defuns I defined along the lines of what you want:
(defun forward-symbol ()
"Move forward over a symbol."
(interactive)
(forward-word 1)
(while (eq (char-syntax (following-char)) ?\_)
(forward-word 1)
)
)
(defun backward-symbol ()
"Move backward over a symbol."
(interactive)
(backward-word 1)
(while (eq (char-syntax (preceding-char)) ?\_)
(backward-word 1)
)
)
(defun forward-symbol-append ()
""
(interactive)
(unless mark-active (set-mark (point)))
(call-interactively 'forward-symbol)
)
(defun backward-symbol-append ()
""
(interactive)
(unless mark-active (set-mark (point)))
(call-interactively 'backward-symbol)
)
(defun select-symbol-at-point ()
"Select word at point."
(interactive)
(let ((syntax (char-syntax (following-char))))
(if (or (eq syntax ?\w)
(eq syntax ?\_))
(progn
(backward-symbol)
(set-mark (point))
(forward-symbol-append)
)
(progn
(skip-syntax-backward (char-to-string syntax))
(set-mark (point))
(skip-syntax-forward (char-to-string syntax))
)
)
)
)
(global-set-key [(meta f)] 'forward-symbol)
(global-set-key [(meta b)] 'backward-symbol)
(global-set-key [C-S-right] 'forward-symbol-append)
(global-set-key [C-S-left] 'backward-symbol-append)
(global-set-key [(meta control w)] 'select-symbol-at-point)
You should be able to adapt these for M-d.
HTH,
sandip
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: word delimiter
2003-03-05 2:01 ` Sandip Chitale
@ 2003-03-05 7:27 ` Sandip Chitale
0 siblings, 0 replies; 6+ messages in thread
From: Sandip Chitale @ 2003-03-05 7:27 UTC (permalink / raw)
Here you go:
(defun kill-symbol-forward ()
"Kill characters forward until encountering the end of a symbol."
(interactive)
(kill-region (point) (progn (call-interactively 'forward-symbol)
(point))))
(defun kill-symbol-backward ()
"Kill characters backward until encountering the beginningof a symbol."
(interactive)
(kill-region (point) (progn (backward-symbol) (point))))
(global-set-key [(meta b)] 'kill-symbol-backward)
(global-set-key [(meta d)] 'kill-symbol-forward)
HTH,
sandip
"Sandip Chitale" <sandipchitale@yahoo.com> wrote in message
news:b607d812.0303041801.26fea909@posting.google.com...
> I see that people are suggesting modifying the syntax of '_' to word.
> It is related to the discussion if following thread:
>
>
http://groups.google.com/groups?dq=&hl=en&lr=lang_en&ie=UTF-8&threadm=84bs0w
piim.fsf%40lucy.is.informatik.uni-duisburg.de&prev=/groups%3Fdq%3D%26num%3D2
5%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26group%3Dgnu.emacs.help%26start%3D2
5
>
> Someone else suggested that modifying the syntax may be too drastic
> because
> it will affect other commands. Instead you should define new defuns
> which
> do the work.
>
> Here is some defuns I defined along the lines of what you want:
>
> (defun forward-symbol ()
> "Move forward over a symbol."
> (interactive)
> (forward-word 1)
> (while (eq (char-syntax (following-char)) ?\_)
> (forward-word 1)
> )
> )
>
> (defun backward-symbol ()
> "Move backward over a symbol."
> (interactive)
> (backward-word 1)
> (while (eq (char-syntax (preceding-char)) ?\_)
> (backward-word 1)
> )
> )
>
> (defun forward-symbol-append ()
> ""
> (interactive)
> (unless mark-active (set-mark (point)))
> (call-interactively 'forward-symbol)
> )
>
> (defun backward-symbol-append ()
> ""
> (interactive)
> (unless mark-active (set-mark (point)))
> (call-interactively 'backward-symbol)
> )
>
> (defun select-symbol-at-point ()
> "Select word at point."
> (interactive)
> (let ((syntax (char-syntax (following-char))))
> (if (or (eq syntax ?\w)
> (eq syntax ?\_))
> (progn
> (backward-symbol)
> (set-mark (point))
> (forward-symbol-append)
> )
> (progn
> (skip-syntax-backward (char-to-string syntax))
> (set-mark (point))
> (skip-syntax-forward (char-to-string syntax))
> )
> )
> )
> )
>
> (global-set-key [(meta f)] 'forward-symbol)
> (global-set-key [(meta b)] 'backward-symbol)
> (global-set-key [C-S-right] 'forward-symbol-append)
> (global-set-key [C-S-left] 'backward-symbol-append)
> (global-set-key [(meta control w)] 'select-symbol-at-point)
>
>
> You should be able to adapt these for M-d.
>
> HTH,
> sandip
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-03-05 7:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-04 18:34 word delimiter Peter Lee
2003-03-04 19:18 ` Jesper Harder
2003-03-04 19:46 ` Kevin Rodgers
2003-03-04 22:14 ` kgold
2003-03-05 2:01 ` Sandip Chitale
2003-03-05 7:27 ` Sandip Chitale
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).