help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: key binding for highlighting


From: sam jesse
Subject: Re: key binding for highlighting
Date: Sat, 1 Aug 2009 09:34:34 +1000

using GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) of 2008-09-07 on SOFT-MJASON under window XP.
the command to mark-word did not make the word at point.

after googleing, I found this code which suppose to be fired M-8 to make the word, the next fire for the sentence and the 3rd fire for the whole paragraph. but it is not working in my system.
please try on yours and report back. thx

;; by Nikolaj Schumacher, 2008-10-20. Released under GPL.
(defun semnav-up (arg)
  (interactive "p")
  (when (nth 3 (syntax-ppss))
    (if (> arg 0)
        (progn
          (skip-syntax-forward "^\"")
          (goto-char (1+ (point)))
          (decf arg))
      (skip-syntax-backward "^\"")
      (goto-char (1- (point)))
      (incf arg)))
  (up-list arg))

;; by Nikolaj Schumacher, 2008-10-20. Released under GPL.
(defun extend-selection (arg &optional incremental)
  "Select the current word.
Subsequent calls expands the selection to larger semantic unit."
  (interactive (list (prefix-numeric-value current-prefix-arg)
                     (or (and transient-mark-mode mark-active)
                         (eq last-command this-command))))
  (if incremental
      (progn
        (semnav-up (- arg))
        (forward-sexp)
        (mark-sexp -1))
    (if (> arg 1)
        (extend-selection (1- arg) t)
      (if (looking-at "\\=\\(\\s_\\|\\sw\\)*\\_>")
          (goto-char (match-end 0))
        (unless (memq (char-before) '(?\) ?\"))
          (forward-sexp)))
      (mark-sexp -1))))

(global-set-key (kbd "M-8") 'extend-selection)
; code end ********

On Sat, Aug 1, 2009 at 7:41 AM, Richard Riley <rileyrgdev@gmail.com> wrote:
sam jesse <revrvr@gmail.com> writes:

> Hi
>
> what do I need to put in my .emacs so that when I hit say F5 key, emacs highlights the word at the cursor?
> I will try to apply the same for the sentence with F6 and the paragraph with F7.
>
> thanks
>

You might want mark-word.

You can then extend the selection ot just delete/copy etc.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]