Page 1 of 1

help delete-to-word

Posted: Mon Dec 14, 2009 3:56 am
by lecheel
if current at point is [ \t\r\n] (re-search-forward "[ \t\r\n]+" nil t)
otherwise (kill-word)

(defun delete-to-word ()
(interactive)
(setq myChar (thing-at-point 'char))
(if (string-match "[ \t\r\n]" myChar)
(progn
(re-search-forward "[ \t\r\n]+" nil t)
(replace-match "" nil nil))
(kill-word))
)

if: Wrong number of arguments: #[(arg) "Á`^Hv\210`\"\207" [arg kill-region] 3 2119065 "p"], 0

Re: help delete-to-word

Posted: Tue Dec 15, 2009 5:22 am
by lecheel
(defun le-kill-word (arg)
(interactive "p")
(setq myChar (thing-at-point 'char))
(if (string-match "[ \t\r\n]" myChar)
(progn
(re-search-forward "[ \t\r\n]+" nil t)
(replace-match "" nil nil))
(kill-region (point) (progn (forward-word arg) (point)))
)
)

why can not call kill-word directly

Re: help delete-to-word

Posted: Tue Dec 15, 2009 6:46 am
by ramarren
KILL-WORD takes an argument. Emacs is self-documenting, if you are unsure how to use a function use 'C-h f', which by default is bound to describe-function command.

Re: help delete-to-word

Posted: Thu Dec 17, 2009 6:49 am
by dmitry_vk
Ramarren wrote:KILL-WORD takes an argument. Emacs is self-documenting, if you are unsure how to use a function use 'C-h f', which by default is bound to describe-function command.
Or, better, enable the `eldoc-mode' that will show description of function under cursor in the minibuffer.

Re: help delete-to-word

Posted: Fri Dec 18, 2009 2:10 am
by lecheel
freshman using emacs thanks guy :-D