help delete-to-word

Discussion of programming Lisps using Emacs, including SLIME and other tools

help delete-to-word

Postby 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

Postby 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
lecheel
 
Posts: 5
Joined: Sat Dec 05, 2009 6:49 am

Re: help delete-to-word

Postby 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.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: help delete-to-word

Postby 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.
dmitry_vk
 
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan

Re: help delete-to-word

Postby lecheel » Fri Dec 18, 2009 2:10 am

freshman using emacs thanks guy :-D
lecheel
 
Posts: 5
Joined: Sat Dec 05, 2009 6:49 am


Return to Emacs

Who is online

Users browsing this forum: No registered users and 2 guests

cron