emacs/var/elfeed/db/data/1d/1d2bd70cb11ca24adb32c69f5bc51c39d19647b6
2022-01-03 12:49:32 -06:00

1 line
2.9 KiB
Plaintext

<!-- SC_OFF --><div class="md"><p>Hi everyone,</p> <p>I use Doom Emacs with Evil and the <code>+everywhere</code> flag. I read Wiki pages with eww and I would like jump to urls with the same visual approach as <code>evilem-motion-*</code>, i.e., where the candidates are prefixed by letters.</p> <h1>Defining the motion</h1> <p>I followed the definition of the <a href="https://github.com/PythonNut/evil-easymotion/blob/master/evil-easymotion.el#L340">evilem-motion-*</a> motions to create a new one based on <code>shr-next-link</code>:</p> <pre><code>(after! evil-easymotion (evilem-make-motion evilem-motion-shr-next-link #&#39;shr-next-link :scope &#39;line)) (map! :after eww :map eww-mode-map (:prefix &quot;g&quot; :n &quot;&lt;tab&gt;&quot; #&#39;evilem-motion-shr-next-link)) </code></pre> <p>Which works as intended, but only highlight links in the current line while I wanted to highlight all the links in the window. This happend because I am using <code>:scope &#39;line</code>.</p> <h1>Defining the <code>window</code> scope</h1> <p>I managed to understand what was the scope handled by <code>evil-easymotion</code>, i.e., everything recognised by the <code>thing-at-point</code> function. But I didn&#39;t find any predefined <code>thing</code> matching the window. Thus, I have created a new one:</p> <pre><code>(defun window-bounds-of-window-at-point () &quot;Return the start and end points of a window.&quot; (save-excursion (message &quot;%d-%d&quot; (window-start) (window-end)) (cons (window-start) (window-end)))) (put &#39;window &#39;bounds-of-thing-at-point &#39;window-bounds-of-window-at-point) </code></pre> <p>And then I changed the scope of <code>evilem-motion-shr-next-link</code> from <code>&#39;line</code> to <code>&#39;window</code>.</p> <h1>Problem</h1> <p>Everything work well, except that <code>(window-end)</code> returns a different value when I run <code>evilem-motion-shr-next-link</code> via the eval prompt, i.e., <code>pp-eval-expression</code>, or via my keybinding.</p> <p>For instance, on <code>(eww &quot;https://www.emacswiki.org/emacs/IntegerAtPoint&quot;)</code> with the cursor at the beginning, the debuging message in <code>window-bounds-of-window-at-point</code> returns:</p> <ul> <li><p><code>1-870</code> via the keybinding</p></li> <li><p><code>1-1531</code> via the eval prompt</p></li> </ul> <h1>Questions</h1> <ul> <li><p>Does someone know why there is this difference between the two approaches to call the function?</p></li> <li><p>Is there a simpler and more efficient solution to what I am doing?</p></li> </ul> <p>Thank you in advance!</p> <p>Edit: Fix the formatting</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/Zar_Rok"> /u/Zar_Rok </a> <br/> <span><a href="https://www.reddit.com/r/emacs/comments/q766fp/strange_behavior_when_defining_a_thingatpoint/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/emacs/comments/q766fp/strange_behavior_when_defining_a_thingatpoint/">[comments]</a></span>