[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
- Copy whitespace-delimited text to variable, Tim Johnson, 2018/03/07
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/08
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/08
- Re: Copy whitespace-delimited text to variable,
Tim Johnson <=
- Message not available
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/09
- Re: Copy whitespace-delimited text to variable, Tim Johnson, 2018/03/09
- Message not available
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/10
- Re: Copy whitespace-delimited text to variable, Tim Johnson, 2018/03/11
- Message not available
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/11