[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Copy whitespace-delimited text to variable
From: |
Emanuel Berg |
Subject: |
Re: Copy whitespace-delimited text to variable |
Date: |
Thu, 08 Mar 2018 07:10:26 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
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) ))))))
--
underground experts united
http://user.it.uu.se/~embe8573
- Copy whitespace-delimited text to variable, Tim Johnson, 2018/03/07
- Re: Copy whitespace-delimited text to variable,
Emanuel Berg <=
- Re: Copy whitespace-delimited text to variable, Emanuel Berg, 2018/03/08
- Re: Copy whitespace-delimited text to variable, Tim Johnson, 2018/03/08
- 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