all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Copy whitespace-delimited text to variable
Date: Thu, 08 Mar 2018 07:10:26 +0100	[thread overview]
Message-ID: <86zi3jqer1.fsf@zoho.com> (raw)
In-Reply-To: mailman.10256.1520462425.27995.help-gnu-emacs@gnu.org

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


       reply	other threads:[~2018-03-08  6:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.10256.1520462425.27995.help-gnu-emacs@gnu.org>
2018-03-08  6:10 ` Emanuel Berg [this message]
2018-03-08  6:37   ` Copy whitespace-delimited text to variable Emanuel Berg
2018-03-08 16:15   ` Tim Johnson
     [not found]   ` <mailman.10281.1520525754.27995.help-gnu-emacs@gnu.org>
2018-03-09  6:47     ` Emanuel Berg
2018-03-09 16:20       ` Tim Johnson
     [not found]       ` <mailman.10333.1520612428.27995.help-gnu-emacs@gnu.org>
2018-03-11  0:21         ` Emanuel Berg
2018-03-11 16:18           ` Tim Johnson
     [not found]           ` <mailman.10425.1520785140.27995.help-gnu-emacs@gnu.org>
2018-03-11 22:17             ` Emanuel Berg
2018-03-07 22:40 Tim Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86zi3jqer1.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.