unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: sandipchitale@yahoo.com (Sandip Chitale)
Subject: Re: word delimiter
Date: 4 Mar 2003 18:01:53 -0800	[thread overview]
Message-ID: <b607d812.0303041801.26fea909@posting.google.com> (raw)
In-Reply-To: b438fg$v3m$1@news.btv.ibm.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=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

  reply	other threads:[~2003-03-05  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2003-03-05  7:27     ` Sandip Chitale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b607d812.0303041801.26fea909@posting.google.com \
    --to=sandipchitale@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).