emacs-devel
[Top][All Lists]
Advanced

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

Re: Word search


From: Juri Linkov
Subject: Re: Word search
Date: Wed, 12 Mar 2008 02:35:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu)

> PS: Oh and for your C-w, I personally think we should have a generic
> C-w binding in minibuffer-local-map.

The following patch implements this:

Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.198
diff -c -r1.198 bindings.el
*** lisp/bindings.el    5 Mar 2008 04:09:24 -0000       1.198
--- lisp/bindings.el    12 Mar 2008 00:32:07 -0000
***************
*** 773,779 ****
    ;; indent-for-tab-command).  The alignment that indent-relative tries to
    ;; do doesn't make much sense here since the prompt messes it up.
    (define-key map "\t"    'self-insert-command)
!   (define-key minibuffer-local-map [C-tab] 'file-cache-minibuffer-complete))
  
  (define-key global-map "\C-u" 'universal-argument)
  (let ((i ?0))
--- 773,780 ----
    ;; indent-for-tab-command).  The alignment that indent-relative tries to
    ;; do doesn't make much sense here since the prompt messes it up.
    (define-key map "\t"    'self-insert-command)
!   (define-key map [C-tab] 'file-cache-minibuffer-complete)
!   (define-key map "\C-w"  'minibuffer-yank-word-or-char))
  
  (define-key global-map "\C-u" 'universal-argument)
  (let ((i ?0))

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.904
diff -c -r1.904 simple.el
*** lisp/simple.el      3 Mar 2008 02:16:00 -0000       1.904
--- lisp/simple.el      12 Mar 2008 00:32:31 -0000
***************
*** 1393,1398 ****
--- 1407,1435 ----
    ;; Return the width of everything before the field at the end of
    ;; the buffer; this should be 0 for normal buffers.
    (1- (minibuffer-prompt-end)))
+ 
+ (defun minibuffer-yank-word-or-char ()
+   "Pull next character or word from buffer into the minibuffer.
+ 
+ If the mark is active in the minibuffer, then kill text between point
+ and mark in the minibuffer using `kill-region'.
+ 
+ Otherwise, get the next word or character from the original buffer
+ and append it to the minibuffer."
+   (interactive)
+   (if mark-active
+       (kill-region (point) (mark))
+     (insert
+      (with-current-buffer (other-buffer (current-buffer) t)
+        (buffer-substring-no-properties
+         (point)
+         (progn
+           (if (or (= (char-syntax (or (char-after) 0)) ?w)
+                   (= (char-syntax (or (char-after (1+ (point))) 0)) ?w))
+               (forward-word 1)
+             (forward-char 1))
+           (point)))))))
+ 
  
  ;; isearch minibuffer history
  (add-hook 'minibuffer-setup-hook 'minibuffer-history-isearch-setup)

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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