This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

help delete-to-word

5 posts · 6144 views

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

(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

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

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

freshman using emacs thanks guy :-D