Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I double click 'abcd_efg', emacs selects the part 'abcd' or 'efg' depending on what I click. How can I select the whole string 'abcd_efg' instead? Thank you.

share|improve this question

migrated from stackoverflow.com Feb 20 '13 at 21:47

This question came from our site for professional and enthusiast programmers.

3 Answers 3

You can call (modify-syntax-entry ?_ "w") that will define underscore as part of the word.

share|improve this answer

Either do what @jcubic suggested or just double-click the _ char in the symbol name. That's what I do.

That way, you can do either: select a word (e.g., a piece of a symbol name) or select an entire symbol name. Yes, you have to pay a little more attention to where you click, but you get more flexibility.

share|improve this answer

I use this one, which I slightly modified from a google post (https://groups.google.com/forum/#!topic/gnu.emacs.help/9UDFLLjBeKU)

(defun get-word-boundary ()
 "Return the boundary of the current word.
 The return value is of the form: (cons pos1 pos2).
 "
 (save-excursion
  (let (p1 p2)
   (progn
    (skip-chars-backward "-A-Za-z0-9_.") ;; here you can choose which symbols to use
    (setq p1 (point))
    (skip-chars-forward "-A-Za-z0-9_.") ;; put the same here
    (setq p2 (point)))
   (cons p1 p2)
  ))
)
(defun select-word ()
"Mark the url under cursor."
(interactive)
;  (require 'thingatpt)
(let (bds)
  (setq bds (get-word-boundary))

  (set-mark (car bds))
  (goto-char (cdr bds))
  )
)
(global-set-key [double-mouse-1] 'select-word)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.