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 "+")))


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

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

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