Emacs: commands in popup frames with emacsclient

Поделиться
HTML-код
  • Опубликовано: 31 янв 2025

Комментарии • 53

  • @Stratopeter87
    @Stratopeter87 4 месяца назад +2

    This is super useful, thanks a lot! Here is my use-case: I love the Emacs Calculator and would like to use it more often while not working directly in Emacs. With your macro applied to the `full-calc` command and a system keybinding to open it via the shell command, this works great. However, I had to use Keyboard Maestro on MacOS to bring the frame into focus and close it as well as hide Emacs when I hit escape. This way, it feels like “toggling” the calculator, although it may be smoother if I could just show/hide the frame without creating/destroying it all the time.

  • @cool4skull
    @cool4skull 4 месяца назад +6

    Another grate post. Thanks prot

  • @Partycatlol
    @Partycatlol 4 месяца назад

    Hey Prot, thanks for the video!
    I'm using a similar popup frames setup to look up words in a dictionary. I wanted to mention a few things I found useful when setting that up:
    1. Passing '-c/--create-frame' to emacsclient will tell it to create a new frame, useful when you want to call a command that doesn't create a frame by itself e.g. `emacsclient -c -e '(calibredb)'`.
    2. You can control the size of the frame by changing its frame parameters 'width' and 'height' (see also 'name' for frame title and 'top' and 'left' for frame position). Conveniently emacsclient allows passing frame parameters via the -F flag.
    3. I also like to hide the modeline with (setq-local mode-line-format nil).

    • @protesilaos
      @protesilaos  4 месяца назад

      You are welcome! One downside I found for "-c" is that we cannot store the frame object it generates, so we cannot target it later. I do use this though for something else.
      Do you configure the default-frame-alist? For me this is enough to style all my frames. What you suggest is fine, of course. In the code I showed here, the parameters are passed to make-frame.
      I think what you do with the modeline has a permanent side effect for the given buffer. If you close the frame and then visit that buffer in another frame, the modeline is still hidden. Is this the desired behaviour?

    • @Partycatlol
      @Partycatlol 4 месяца назад

      @@protesilaos Fair enough, I should've mentioned that I reuse the same buffer in which 'delete-frame' is bound to 'q' and a permanently hidden modeline is what I want. I handle the 'quit condition during user input the same way you show in the video.
      Good point about the default-frame-alist. I completely forgot about it as my tiling wm controls the size of regular (not floating) emacs frames.

    • @protesilaos
      @protesilaos  4 месяца назад +1

      @Partycatlol Good to know about the delete-frame!
      Indeed, the display-frame-alist is not that useful in a tiling WM. As an aside, I remember doing something with frame names and bspwm external rules, where some frames would break from the tiling scheme and appear in a floating state. It was neat, though not essential.

  • @kendawg_mcawesome
    @kendawg_mcawesome 4 месяца назад

    A thing of beauty, you're a lifesaver Prot!

  • @VimOneLove
    @VimOneLove 4 месяца назад +3

    Prot always with the drip.

    • @protesilaos
      @protesilaos  4 месяца назад +2

      I am not sure what "drip" means here, but it sounds positive. Thank you!

    • @VimOneLove
      @VimOneLove 4 месяца назад +2

      @@protesilaos Haha it's just gen z slang for "fashionable clothes". You always wear the best shirts.

    • @protesilaos
      @protesilaos  4 месяца назад +1

      @VimOneLove Cool!

  • @stevechan5315
    @stevechan5315 4 месяца назад

    So useful

  • @shareclipsave
    @shareclipsave 4 месяца назад +5

    Hi Prot, may I make a video suggestion? Can you do a video on how you learn? If you were to acquire a new skill, what would be your process and tools that you would use?

    • @protesilaos
      @protesilaos  4 месяца назад +3

      Interesting, thank you! It is not an easy topic to cover though because a large part of it comes down to the individual (e.g. some people are visual thinkers, but I am not).

    • @shareclipsave
      @shareclipsave 4 месяца назад

      @@protesilaos Oh yeah but I think you have some interesting things you can say since you're self-taught in tech (Linux, shell scripting, Lisp, etc.)

    • @shareclipsave
      @shareclipsave 4 месяца назад

      @@protesilaos I maybe wrong on this but you never went to school for your tech skills?

    • @protesilaos
      @protesilaos  4 месяца назад +1

      @shareclipsave Fine, I will give it a try as soon as I can. About the tech skills, I did indeed acquire those on my own, just by tinkering with Linux and stuff.

    • @shareclipsave
      @shareclipsave 4 месяца назад +1

      @@protesilaos Just a suggestion. If I sounded forceful, it was not my intention. I'm sure you always got something cooking in your noggin.

  • @gnu-lynx2501
    @gnu-lynx2501 4 месяца назад

    Hello emacs frens! Using elisp functions from outside is handy. Of course there is `emacs --script` for batch processing. But using the elisp brain of an already running emacs server is quicker, simpler, and you can even go forth with the result in your running emacs. Try:
    echo 'Occam%27s_razor' | { read message; echo "$message"; emacsclient -e '(progn (pop-to-buffer (generate-new-buffer "*pipe*")) (insert (url-unhex-string "'$message'")) (princ (buffer-string)))' ; }
    Using one of emacs' many nifty functions for processing certain strings. No need for other scripting languages anymore! :-)

  • @nicolassemrau603
    @nicolassemrau603 4 месяца назад +1

    I like this code as much as Prot recently came to like the word "concomitant". ;)

    • @protesilaos
      @protesilaos  4 месяца назад +3

      Haha! I had to look this up. A quick look suggests that the first use of it on my website was in 2012. There are 172 matches since then (over 1600+ publications).

    • @nicolassemrau603
      @nicolassemrau603 4 месяца назад +1

      @@protesilaos I read your RSS feed for a few months now. After looking through your older stuff where I never saw it, I recently noticed the first occurence in a new article (and I had to look up the meaning - another thing I learned thanks to you), a new article or two later - there it was again! A few weeks later - third time! :D All in the politics and philosopy sections. Soto me it looked a bit like you recently learned of "concomitant" yourself and now like to put this into your new writings as an especially handy expression, haha. :)

    • @protesilaos
      @protesilaos  4 месяца назад +1

      Good to know!

  • @akartha
    @akartha 3 месяца назад

    I kept getting a "*ERROR*: Unknown terminal type", until I modified one line in the code as
    (let ((frame (make-frame '((prot-window-popup-frame . t) (window-system . x)))))
    Now it works beautifully. Thanks Prot!

    • @protesilaos
      @protesilaos  3 месяца назад

      You are welcome! I wonder why this was necessary though. Is your regular system something else and its value is not picked up automatically?

  • @rickdixon1928
    @rickdixon1928 4 месяца назад +1

    Mr Prot, great stuff as always! One question: could you have foregone using hooks to delete the new frame and instead have just added (delete-frame frame) as the next expression after (call-interactively ',command)? Thanks for any help.

    • @protesilaos
      @protesilaos  4 месяца назад +1

      @rickdixon1928 It is as @lc2000 explains. Without the hooks we will have the frame close in moments that are not right.

    • @rickdixon1928
      @rickdixon1928 4 месяца назад

      @@lc2000 and @protesilaos Thank you!

  • @cone-eater
    @cone-eater 4 месяца назад

    This is very cool! Thank you Prot for sharing.
    It would be very nice if the empty buffer was not visible in the popup frame. Do you know of any way to achieve that?

    • @protesilaos
      @protesilaos  4 месяца назад

      You are welcome! About the empty buffer, I don't know if there is a way to have the functionality without it. Some buffer needs to be there. Whether it is this hidden one or some other is a matter of choice.

    • @ozziem
      @ozziem 4 месяца назад

      I have done something similar for org-capture for some time and the extra buffer annoyed me. Since I only use it for org-capture, I just added an 'org-capture-mode-hook' that calls 'delete-other-windows' if the frame has the "special unique name". (Though doing this for every "popup function" would somewhat negate the elegance of Prot's macro-based solution.)

  • @theemacsen1518
    @theemacsen1518 4 месяца назад +3

    Common Prot W

  • @mmontone
    @mmontone 4 месяца назад +1

    An Emacs powered desktop environment?

    • @protesilaos
      @protesilaos  4 месяца назад

      Kind of. This is Xfce on Debian, though I do use Emacs for most of my computing.

  • @RamsesAldama
    @RamsesAldama 4 месяца назад

    why does prot-window-define-popup-frame has to be a macro? can it be just a function?

    • @protesilaos
      @protesilaos  4 месяца назад +1

      It does not need to be a macro. I prefer it this way though because it streamlines the definition of new functions. Without it, we would have to define a new function with more boilerplate each time.

  • @johnhammer8668
    @johnhammer8668 4 месяца назад

    What window manager are you using ? also why the emacs does not take the full screen space (not the popup frame, the other frame in which you demoed the code)?

    • @protesilaos
      @protesilaos  4 месяца назад

      This is Xfce on Debian stable.

  • @blahblah49000
    @blahblah49000 4 месяца назад

    Weird, was my comment here deleted? Did I say something unwelcome?

    • @protesilaos
      @protesilaos  4 месяца назад +1

      I have no idea. I never delete comments. Maybe post it again?

    • @blahblah49000
      @blahblah49000 4 месяца назад +2

      @@protesilaos I guess it must have been detected by RUclips as spam, then, which is strange. My comment just pointed out the "yequake" Emacs package which is designed to make this sort of thing easy, and which specifically supports org-capture.

    • @NeroPawn
      @NeroPawn 3 месяца назад

      @@blahblah49000 Same, posted a link to an issue that solves frames not opening correctly in wayland from this same repo and my comment was deleted.

    • @hapst3r
      @hapst3r 2 месяца назад

      @@NeroPawn would you mind to post the link to the issue again? I checked out yequake and am kinda on the verge of dropping it because the frames behave weirdly on wayland.