5

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.

0

3 Answers 3

3

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.

1

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

0

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.