Commit Graph

42 Commits

Author SHA1 Message Date
0a715cc3f2 refactor: (if|when)-let -> (if|when)-let*
With the former macros' future in the air (and likely to be targeted in
future, potentially breaking changes), I'll deal with this now than have
it bite me later.

Ref: https://lists.gnu.org/archive/html/emacs-devel/2024-10/msg00637.html
2025-01-08 19:33:37 -05:00
05e34351ea fix(eval): double prompt when region sent to repl
The +eval/send-region-to-repl command was adding an extra newline when
sending regions to REPLs, causing double prompts to appear. This removes
the extra newline for cleaner REPL interaction across all language modes.

* modules/tools/eval/autoload/repl.el (+eval/send-region-to-repl):
remove concatenation of newline after region
2024-12-01 11:21:28 -05:00
1f8c326dfa fix(eval): remove duplicate REPL entries
The method previously used to remove duplicates was incorrect
2024-10-31 21:44:13 -04:00
21f6fb7576 fix(eval): warnings after eval error
This addresses the warning emitted when evaluating elisp in org-mode:

  Warning (org-element): ‘org-element-at-point’ cannot be used in
  non-Org buffer #<buffer debug.org> (emacs-lisp-mode)

Close: #7753
Fix: #7752
Co-authored-by: pysnow530 <pysnow530@users.noreply.github.com>
2024-04-08 19:53:46 -04:00
0cf7824256 refactor(eval): avoid seq-uniq & cl-{first,second}
- While seq.el is likely present, Doom does not guarantee it in
  interactive sesions like it guarantees cl-lib's presence.
- There is no reason to ever use cl-first/cl-second.
2024-04-05 18:54:35 -04:00
b6e7bbbe07 fix(eval): overlay position
Fix: #7732
Close: #7734
Co-authored-by: pysnow530 <pysnow530@users.noreply.github.com>
2024-03-19 20:47:20 -04:00
5daf800ae1 feat(tools): rework REPL selection UI
This displays human-readable versions of the modes whose REPL the user
wishes to open.
2023-03-08 20:31:25 -05:00
0123dd1648 fix(tools): improve detection of available REPLs
Previously, when setting up a prompt for choosing from the available
REPLs, not all known options were detected via the regex pattern. This
commit modularizes the logic and provides a backup for detecting REPLs
that we definitely know about from the `+eval-repls` list.
2023-03-08 20:31:25 -05:00
9d4d5b756a fix(eval): lookup RET binding in insert if evil
Otherwise, if the REPL was not in insert mode the send-to-buffer would
fail.
2022-10-31 16:18:16 +01:00
ad6a3d0f33 refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00
790c2a6d84 fix(eval): eros overlay going off-screen
Evaluating code (and :tools (eval +overlay) enabled) will do one of two
things with the return value:

If long, it will be displayed in a popup window on the bottom of the
frame. If short (<3-4 lines), it will be displayed in an overlay at the
end of the line.

If you happened to have scrolled horizontally (such that the BOL isn't
visible), the overlay would be displayed offscreen and unreadable. Any
attempt to scroll it into view will cause it to disappear (as per its
transient nature). This fix pads each newline in said overlay such that
the overlay is pushed into view.
2022-08-07 19:43:27 +02:00
057e6c531c refactor: replace doom-enlist with ensure-list
doom-enlist is now a deprecated alias for ensure-list, which is built
into Emacs 28.1+ and is its drop-in replacement. We've already
backported it for 27.x users in doom-lib (in 4bf4978).

Ref: 4bf49785fd
2022-08-07 19:43:13 +02:00
7290f85cfd feat(eval): set load-true-file-name & buffer-file-truename
So they are available in evaluated contexts.
2022-01-27 03:50:52 +01:00
aebd4b0c99 docs(eval): explain DWIM behavior 2021-12-18 10:45:17 -05:00
fea561f678 feat(eval): :send-region and :send-buffer handlers
Ref: #2496
2021-12-18 10:45:17 -05:00
c9eb00a217 Fix incorrect newline placement on send-to-REPL
Sending this form to a REPL (like ielm):

  (defun test (n)
    ...)

Will yield:

  (defun test (n
                 ...))

Because our RET emulation doesn't take evil's off-by-one cursor
placement into account.
2021-04-13 18:54:48 -04:00
bac1ff173d Fix non-default REPL's format of command name. 2021-03-13 12:17:42 +07:00
14d341530a tools/eval: always eval elisp in current session
If you used an +eval/* command from a non-emacs-lisp-mode buffer,
quickrun would prompt you for a program to evaluate the code with. If
you selected "emacs" the code would evaluate in an external Emacs
process and return displayed output (stdout).

This commit changes +eval/buffer, +eval/region, and
+eval/region-and-replace (and all the other +eval commands that use
them) to evaluate code in the current session instead.
2021-02-24 18:06:30 -05:00
8bbac4bfb3 Minor refactors 2020-08-08 03:06:26 -04:00
59c5aaad8d Fix error when opening REPL from unsupported mode
"Wrong number of arguments: (_mode fn . plist), 0"
2020-06-19 14:26:57 +10:00
345479c29e Always display evaluated result in popup buffer
If +eval isn't enabled
2020-01-07 14:27:02 -05:00
7ef3bee851 Consider eval output width when deciding how to display it
If ':tools (eval +overlay)' is enabled, eval commands display their
output in a floating overlay at EOL. If the output is longer than
+eval-popup-min-lines (5), it will display it in a popup window instead.

With this, it also will use a popup window if the output is longer than
the minibuffer can display in one line,
2019-12-28 13:53:13 -05:00
2da7c7b168 tools/eval: make set-eval-handler! accept a list of modes
Fixes inline evaluation for emacs-lisp-mode due to 322bca7.
2019-12-20 02:34:29 -05:00
318754c4d2 Prevent eval results from consuming > half the frame 2019-12-05 20:48:53 -05:00
26c8f5c6ef Bytecompiler bytecompiler, won't you shut up 2019-11-23 01:21:25 -05:00
c30d0ab1b7 tools/eval: ensure final newline after repl input #2056
Fix an issue where the final line of send-to-repl input (via gr) isn't
consistently processed.
2019-11-17 01:15:51 -05:00
f54d7a15cd tools/eval: send to repl (via gr) by line #2056 2019-11-16 20:57:04 -05:00
c2db4a8708 tools/eval: add REPL support for +eval/buffer 2019-11-15 00:17:10 -05:00
d0a7cac3ad Fix +eval:region sending whole buffer to REPL #1941 2019-11-12 20:22:38 -05:00
762c374198 Rename +eval-overlay-max-lines -> +eval-popup-min-lines
Generalize variable.
2019-10-29 18:19:02 -04:00
d2fe021bd9 tools/eval: display in minibuffer if below threshold
If it's just a couple lines, display in minibuffer instead.
2019-10-26 03:54:09 -04:00
36c9f7c333 tools/eval: fix popup when +overlay is disabled 2019-10-26 03:53:54 -04:00
84a063ca78 tools/eval: add +overlay feature
Now, inline evaluation will display results in an overlay next to the
cursor, rather than in the minibuffer (unless it gets too big, in which
case it'll use a popup buffer).
2019-10-26 02:12:58 -04:00
a940d07e4b tools/eval: minor refactors 2019-10-24 19:23:17 -04:00
bcdf5eb19a tools/eval: gr now sends to REPL if one is open #1941
And polish other evil repl commands + add docstrings.
2019-10-24 16:56:53 -04:00
0b67251159 tools/eval: associate plist with repl handlers
Also consolidates all REPLs (opened through the :tools eval module)
under one popup rule, which inhibits ESC from prematurely closing
them (#1944), and cleans up after their buffers *only* if their handlers
weren't specified to :persist, e.g.

  (set-repl-handler! 'some-mode #'some-repl-handler :persist t)

Also standardized ESS's REPL commands.
2019-10-23 21:41:23 -04:00
cfcaad4bfc tools/eval: don't select window after send-to-repl #1941
Also:

- Refactors REPL logic
- Open-repl commands now copy selection to new REPL and select
  them (without executing them).
- Send-to-repl now auto-executes by default. Prefix arg = don't auto
  execute
2019-10-23 14:08:15 -04:00
3181933ed1 Minor refactoring and reformatting 2019-10-08 17:42:36 -04:00
bb71f591f8 tools/eval: fix void-variable term-raw-map errors 2019-10-08 17:42:36 -04:00
1aae5c9242 tools/eval: fix extra newlines in term-char-mode REPLs #1836 2019-10-07 12:58:05 -04:00
2214c3175e Minor tweaks across the board 2019-05-21 00:34:32 -04:00
77e4cc4d58 💥 Remove :feature category
:feature was a "catch-all" category. Many of its modules fit better in
other categories, so they've been moved:

- feature/debugger -> tools/debugger
- feature/evil -> editor/evil
- feature/eval -> tools/eval
- feature/lookup -> tools/lookup
- feature/snippets -> editor/snippets
- feature/file-templates -> editor/file-templates
- feature/workspaces -> ui/workspaces

More potential changes in the future:

- A new :term category for terminal emulation modules (eshell, term and
  vterm).
- A new :os category for modules dedicated to os-specific functionality.
  The :tools macos module would fit here, but so would modules for nixos
  and arch.
- A new :services category for web-service integration, like wakatime,
  twitter, elfeed, gist and pastebin services.
2019-04-24 18:16:04 -04:00