help delete-to-word

Discussion of programming Lisps using Emacs, including SLIME and other tools
Post Reply
lecheel
Posts: 5
Joined: Sat Dec 05, 2009 6:49 am

help delete-to-word

Post by lecheel » Mon Dec 14, 2009 3:56 am

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

lecheel
Posts: 5
Joined: Sat Dec 05, 2009 6:49 am

Re: help delete-to-word

Post by lecheel » Tue Dec 15, 2009 5:22 am

(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

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: help delete-to-word

Post by ramarren » Tue Dec 15, 2009 6:46 am

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.

dmitry_vk
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan
Contact:

Re: help delete-to-word

Post by dmitry_vk » Thu Dec 17, 2009 6:49 am

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.

lecheel
Posts: 5
Joined: Sat Dec 05, 2009 6:49 am

Re: help delete-to-word

Post by lecheel » Fri Dec 18, 2009 2:10 am

freshman using emacs thanks guy :-D

Post Reply