[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: word delimiter
From: |
Sandip Chitale |
Subject: |
Re: word delimiter |
Date: |
Wed, 05 Mar 2003 07:27:57 GMT |
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
b607d812.0303041801.26fea909@posting.google.com">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