help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Copy whitespace-delimited text to variable


From: Tim Johnson
Subject: Re: Copy whitespace-delimited text to variable
Date: Thu, 8 Mar 2018 07:15:48 -0900
User-agent: Mutt/1.7.0 (2016-08-17)

* Emanuel Berg <moasen@zoho.com> [180307 21:27]:
> Tim Johnson wrote:
> 
> > Example: in elpy
> > g.args (where cursor is at or following 's')
> > (current-word) would just return 'args', I need 'g.args'
> > and I don't wish to modify the syntax table.
> >
> > Before I roll my own, I'd rather not
> > re-invent the wheel...
> 
> Why not? To quote the barrel racer, just try -
> and you will fly :)
> 
> (defun previous-word ()
>   (interactive)
>   (save-excursion
>     (let((word-stop (progn (backward-word 1)
>                            (forward-word  1)
>                            (point) ))
>          (word-start (re-search-backward "[[:space:]]" (point-min) t)) )
>       (when word-start
>         (message
>          (string-trim
>           (buffer-substring-no-properties word-start word-stop) ))))))
  :) I'm ready to fly ... and have already been using subr-x
  thanks, Emanuel
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



reply via email to

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