5

Here's what's happening, for the second case. You have this in the buffer, with point at position 1 (beginning of buffer): (a) (b) (c) After the first forward-sexp point is just after the first right paren ()). The next (sexp-at-point) returns the first sexp, not the second. Why? Because point is not on the second list ((b)), and it is just after the ...


4

The thingatpt.el API works as follows: (thing-at-point 'symbol) ;=> foo (beginning-of-thing 'symbol) ;=> 42 (end-of-thing 'symbol) ;=> 45 (bounds-of-thing-at-point 'symbol) ;=> (42 . 45) While it's not 100% reliable as it relies on (forward-thing 'symbol) to do the right thing, it's pretty good and one of the better APIs in Emacs. Give it a ...


4

Not sure why it's not in the default set of chars but you can add it yourself. The relevant variable is thing-at-point-file-name-chars. For example: (eval-after-load "thingatpt" (setq thing-at-point-file-name-chars (concat thing-at-point-file-name-chars "+")))


4

Yes, sure - use mapatoms: (defun find-symbols-having-properties (properties) (let (ret) (mapatoms (lambda (s) (when (cl-loop for prop in properties thereis (get s prop)) (push s ret)))) ret)) Now, to get all the "things", we need to do (find-symbols-having-properties '(beginning-...


3

It's not enough to test for properties beginning-op, end-op, bounds-of-thing-at-point, and thing-at-point. A thing can instead be defined by property forward-op or by a forward- THING function. (And some uses of things require the existence of a forward-op or a forward- THING function.) Library thing-cmds.el (code) defines these functions: thgcmd-defined-...


2

because in thingatpt.el the var thing-at-point-file-name-chars is defined: (defvar thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:" "Characters allowable in filenames.") If you set it, that the + is added to the chars, like so: (setq thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:+") then it works like you want it to.


2

To supplement what @phils said - Make . have symbol-constituent syntax in the current syntax table, or in a copy of it. Either define your own replacement function for thing-at-point: (defun my-thg-at-pt (thing &optional no-properties) "..." (let ((stab (copy-syntax-table))) (with-syntax-table stab (modify-syntax-entry ?. "_") (...


2

I use helm-swoop just like what you described, so the same technique can work for you in swiper too. Helm-swoop picks up the input at point and I want it to be selected automatically, so I can instantly overtype it with delete selection mode. I push the selection keys to unread command events, so they are executed automatically when swoop is waiting for ...


2

What you want is something like (kill-new (thing-at-point 'symbol)). When run, it first extracts the symbol at point and then adds it to the kill-ring, i.e. copies it. One caveat you have to keep in mind is that you need an interactive function/lambda in order to be able to invoke it with a keybinding. So actually you can have a binding of the form: (global-...


2

You find the following answer within the code of thing-at-point: (defun start-of-thing-at-point (thing) "Get start of THING at point." (let ((bounds (bounds-of-thing-at-point thing))) (and bounds (car bounds)))) For your examples thing should be either 'word or 'filename. Tested with 26.3.


1

In Emacs 26.3 at least, the allowed characters are hard-coded in thing-at-point-bounds-of-url-at-point; so you would need to modify that function accordingly, to add a backslash to the allowed-chars binding. The comments below on escaping would apply here too: use "\\\\". (And likewise for having no idea whether or not this will have unwanted side-effects.)...


1

While not strictly answering your question regarding one key copy symbol/word at point I like to use expand-region since frequently I want to copy a lot at point without needing to move to the start, mark, move to end and copy. It might be of use. For example, here are bindings to expand and contract the active region (and of course I then need to M-w to ...


1

For completeness, here is what I ended up implementing, based on @Tom's answer: (defun acg/with-marked-input (&rest args) "Mark input of minibuffer. To be used as advice before any function that starts with an initial input in the minibuffer." (run-with-idle-timer 0 nil (lambda () (push 'C-S-right unread-command-events) (...


1

I don't have an answer related to Swiper, sorry. But FWIW, Icicles provides what (I think) you're describing. You can insert buffer text at point into the minibuffer (appending it to what's already there). You can take advantage of this feature for searching by using M-e when incremental-searching. That puts you in the minibuffer to edit the search ...


1

You want something like: (lambda (event) (interactive (list last-command-event)) (posn-set-point (event-end event)) (xref-find-definitions (thing-at-point 'word))) In the case of mouse events, the event contains data about where the event took place, so you can use it to move point where the click happened.


1

That's dependent on the syntax table for the buffer in question. In elisp, for instance, foo.bar is treated as a single symbol. You can specify that . is symbol-constituent in the current buffer's syntax table with: (modify-syntax-entry ?. "_") Unless this is for a custom mode of your own devising, I would suggest that you try to establish if there is a ...


1

Made a modified version of @håkon-hægland's answer, its mostly the same except: It takes a line terminating character. White-space after the terminating character is supported(doesn't prevent moving to the next line). The result is joined into a single line with the terminating-char removed from the end of each line. Fixes a bug when the line is at the ...


1

If you do not want to delve into the source of thing-at-point, you could simply use a while loop. For example: (defun my-extract-lines () "Extract line(s) at point. Multiple lines (below the current) are extracted if they end with a backslash character. Returns the line(s) as a string with no properties." (interactive) (save-excursion (let* ((...


1

I would expect symbol-at-point to be reliable. Given that you yourself tagged this question with thing-at-point, are you asking in particular whether there are flaws with this method?


Only top voted, non community-wiki answers of a minimum length are eligible