• Emacs tricks thread!

    From Arch@archenoth@tilde.town to tilde.text on Tue Apr 27 17:05:52 2021
    What kind of tricks do you all have for Emacs?

    They can be big and fancy, or small little usability features others
    might not know about!

    What sorts of less-obvious tidbits of information about Emacs do you all possess?
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Tue Apr 27 17:08:46 2021
    A simple one to start out is if you have dired open, you can use C-x C-q
    to turn off the readonly flag of the buffer, which allows you to edit it
    like a text file.

    If you C-x C-s that buffer, all the changes you make to the filenames,
    owners, and so on will be written back to the files!

    That means you can use a macro to literally transform directories of
    files in extremely novel ways.
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Tue Apr 27 17:37:05 2021
    If you have two dired windows open, you can use them like a commander
    inteface!

    That's because operations like copying (C) and moving (R) will select
    the other buffer's path when you hit Down in the minibuffer when it asks
    you for a destination. Meaning moving things between both panels is
    really easy.
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 11:05:38 2021
    Arch <archenoth@tilde.town> writes:

    What kind of tricks do you all have for Emacs?

    I've bound...

    (global-set-key (kbd "<f5>") 'revert-buffer)

    ...to have reloading (sommetimes the fastest way to activate in document settings) to the usual place known from browsers and for faster buffer switching andd long before that...

    (global-set-key [f12] 'buffer-menu)

    ...to pop of the whole buffer list.

    And since noticing the difference in these definitions, I'm scratching
    my head about which one is the "better" way to do it.

    No tricks harmed for this.

    What sorts of less-obvious tidbits of information about Emacs do you all possess?

    I played a bit with EXWM (emacs as WM) but always managed to get it
    deadlocked or other hangups. I really hope this someday will be good
    enough.

    https://yeti.tilde.institute/brain/emacs.html#exwm

    And I do increasingly more stuff in eshell (plus tramp). Having one
    emacs at home which can access my stuff on remote systems definitely is
    easier to manage than a finetuned emacs on every system. So having a
    look at tramp costs getting used to some no so cute paths/filenames, but
    pays back a lot and fast. Aaaaand sudo/su-editing via tramp! Again:
    One config less (no emacs config for root), just a special case for
    tramp.

    Hmmmm... I didn't try dired with su/sudo-paths yet... ***cough!***

    | /sudo:root@cubietruck1:/:
    | total 103
    | drwxr-xr-x 23 root root 4096 Jul 3 2020 .
    | drwxr-xr-x 23 root root 4096 Jul 3 2020 ..
    | drwxr-xr-x 2 root root 4096 Feb 14 19:45 bin
    | drwxr-xr-x 4 root root 3072 Apr 27 18:39 boot
    | ...

    ...ok!

    What I'm searching is a way to have 2 elpher buffers open at the same
    time... comes time, comes wheel... or such...

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 11:32:26 2021
    | Welcome to the Emacs shell
    |
    | ~ $ emacs-uptime
    | 22 days, 0 hours, 27 minutes, 6 seconds
    | ~ $ █

    "&%//&=//==)(perl!perl!perl!!!
    Fscking kernel update reboots ... :-/
    ***sigh!***
    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 08:05:18 2021
    yeti <yeti@tilde.institute> writes:

    Arch <archenoth@tilde.town> writes:

    What kind of tricks do you all have for Emacs?

    I've bound...

    (global-set-key (kbd "<f5>") 'revert-buffer)

    ...to have reloading (sommetimes the fastest way to activate in document settings) to the usual place known from browsers and for faster buffer switching andd long before that...

    Oh yeah! This one is often bound to "g" for modes where you don't insert
    text, and I've definitely found myself hitting that a lot.

    It's also nice to be able to M-x auto-revert-mode, since that works in a
    loooot of places that a lot of people don't expect.

    Like, I sometimes use it in dired buffers, or the buffer list to watch
    buffer sizes change while doing things--or to watch my processes come
    and go in M-x process-list. (C-c C-s in eshell)

    (global-set-key [f12] 'buffer-menu)

    ...to pop of the whole buffer list.

    And since noticing the difference in these definitions, I'm scratching
    my head about which one is the "better" way to do it.

    No tricks harmed for this.

    Hee. Nice!

    I have pretty strong muscle memory for C-x C-b at this point, though a
    single keystroke for something like that is probably a lot more
    convenient. (I know I'd often set "M-x compile" to [f5] too, for
    example)

    As for which keymap style is "better", that's entirely up to you!

    The function call is probably more "idiomatic" because key chords are represented like "[?C-x ?l]" in the second format...which is a lot
    different than how you usually see keys in documentation--but it's also sliiiiightly faster, since that's actually a literal that the (kbd ...) function would normally spit out.


    What sorts of less-obvious tidbits of information about Emacs do you all
    possess?

    I played a bit with EXWM (emacs as WM) but always managed to get it deadlocked or other hangups. I really hope this someday will be good
    enough.

    https://yeti.tilde.institute/brain/emacs.html#exwm

    I should really play around with exwm someday. A lot of tiling window
    managers kinda remind me of Emacs already, and maybe this one would feel
    comfy enough to stick with.


    And I do increasingly more stuff in eshell (plus tramp). Having one
    emacs at home which can access my stuff on remote systems definitely is easier to manage than a finetuned emacs on every system. So having a
    look at tramp costs getting used to some no so cute paths/filenames, but
    pays back a lot and fast. Aaaaand sudo/su-editing via tramp! Again:
    One config less (no emacs config for root), just a special case for
    tramp.

    Hmmmm... I didn't try dired with su/sudo-paths yet... ***cough!***

    | /sudo:root@cubietruck1:/:
    | total 103
    | drwxr-xr-x 23 root root 4096 Jul 3 2020 .
    | drwxr-xr-x 23 root root 4096 Jul 3 2020 ..
    | drwxr-xr-x 2 root root 4096 Feb 14 19:45 bin
    | drwxr-xr-x 4 root root 3072 Apr 27 18:39 boot
    | ...

    ...ok!

    Heck yeahh!! TRAMP is amazing.

    I like how you can just like...cd to TRAMP paths in eshell and just have
    it "work". I also dig the way you can chain TRAMP connections with "|".

    So like, in eshell, you can just cd to the sudo root@localhost shorthand

    cd /sudo::/

    to quickly get a root prompt, or (this one requires adding docker-tramp)

    cd /sshx:place|docker:container:/

    to open a connection to a docker container on a host an ssh hop away!

    I like this example specifically because containers are often so light
    that they don't even have a text editor on them! So it's really
    practical for being able to edit things. Plus you could use dired or
    eshell with these paths after they are open to copy or move things to or
    from contianers like this, which is usually a very difficult task.

    I often combine this with dired and M-x auto-revert-mode to watch
    folders with debug logs and other program output in it, and to copy said
    files across TRAMP connections to my own disk.

    The opposite is also handy for inserting test files into systems where
    the logistics of doing that are otherwise quite difficult.


    What I'm searching is a way to have 2 elpher buffers open at the same
    time... comes time, comes wheel... or such...

    Gosh, I only started really using elpher recently, so I didn't even
    realize it couldn't do this.

    That's quite the functionality gap, huh? (I wonder how hard it would be
    to implement? I know the gopher git service on elpher's homepage has a
    section for submitted patches, like the one to connect to gemini links
    in tty emacs without erroring out)
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 08:05:49 2021
    RIP
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 14:37:45 2021
    Arch <archenoth@tilde.town> writes:

    RIP

    ???

    Apropos emacs tricks: https://xkcd.com/378

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 09:31:29 2021
    yeti <yeti@tilde.institute> writes:

    Arch <archenoth@tilde.town> writes:

    RIP

    ???

    Oh, I mean like, "RIP uptime"

    RIP is a thing people often say on the internet when talking about
    things that got worked over by something. So, not quite the same "RIP"
    you'd hear someone say normally!

    Like, if I was reading a book and something spilled onto it, even though
    it's probably still readable: RIP book

    Or if I was planning on getting something done, and suddenly something
    that was razor-focused on my very specific intersections of interests
    was released: RIP productivity

    Etc...

    Sometimes people also just shorten that to "RIP" when the context is
    apparent.

    (If that makes sense..?)
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 15:51:05 2021
    Ok... linear message view probably was a bad idea. I might have gotten
    that association right in the zigzag view... "M-C-t"-ing back...

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 10:07:59 2021
    yeti <yeti@tilde.institute> writes:

    Ok... linear message view probably was a bad idea. I might have gotten
    that association right in the zigzag view... "M-C-t"-ing back...

    Ohhh! My bad!

    Should I quote messages more often on usenet in general to make it
    easier to see what they are in response to? Because it never even
    occurred to me that context could be lost without them ^^'
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 16:22:06 2021
    Arch <archenoth@tilde.town> writes:
    Ohhh! My bad!

    No problem!

    Should I quote messages more often on usenet in general to make it
    easier to see what they are in response to?

    We'll find a workflow... 🕉mmmmmmmmm...

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Case Duckworth@acdw@acdw.net to tilde.text on Wed Apr 28 11:35:46 2021
    Arch <archenoth@tilde.town> writes:

    It's also nice to be able to M-x auto-revert-mode, since that works in a loooot of places that a lot of people don't expect.

    I have (global-auto-revert-mode +1) in my ~/.emacs, and I can confirm,
    it's great. I don't even think about it.

    I mean, my use-case is that I want Emacs and the filesystem to mirror
    each other -- I'm on a single-user system where I know that I don't open
    a file in more than one place at a time (though locks would probably fix
    that? Anyway...).

    (global-set-key [f12] 'buffer-menu)

    ...to pop of the whole buffer list.


    I copy-pasted the advice to (global-set-key (kbd "C-x C-b") #'ibuffer) a
    while ago; Honestly I don't use either the buffer-menu or ibuffer that
    much because I have consult installed, which has its consult-buffer
    command that I /love/. It does buffers and recent files (and other
    stuff too, I think, but I just use those).

    Heck yeahh!! TRAMP is amazing.

    For some reason, TRAMP is like, weird for me. I need to do more
    research to make it work.


    What I'm searching is a way to have 2 elpher buffers open at the same
    time... comes time, comes wheel... or such...

    Gosh, I only started really using elpher recently, so I didn't even
    realize it couldn't do this.

    That's quite the functionality gap, huh? (I wonder how hard it would be
    to implement? I know the gopher git service on elpher's homepage has a section for submitted patches, like the one to connect to gemini links
    in tty emacs without erroring out)

    I /think/ that there's a fork that allows multple elpher buffers
    ... hold on (I'm checking) .. yeah there's two on this page:

    gopher://thelambdalab.xyz/1/scripts/browse-git.scm%7Celpher.git

    I haven't tried either, but they're there.

    I'm going to send another message to this thread with the stuff I use.
    I originally meant this reply to just be a response to the elpher thing,
    woops!

    --
    ~ acdw
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Case Duckworth@acdw@acdw.net to tilde.text on Wed Apr 28 11:37:39 2021
    Arch <archenoth@tilde.town> writes:

    It's also nice to be able to M-x auto-revert-mode, since that works in a loooot of places that a lot of people don't expect.

    I have (global-auto-revert-mode +1) in my ~/.emacs, and I can confirm,
    it's great. I don't even think about it.

    I mean, my use-case is that I want Emacs and the filesystem to mirror
    each other -- I'm on a single-user system where I know that I don't open
    a file in more than one place at a time (though locks would probably fix
    that? Anyway...).

    (global-set-key [f12] 'buffer-menu)

    ...to pop of the whole buffer list.


    I copy-pasted the advice to (global-set-key (kbd "C-x C-b") #'ibuffer) a
    while ago; Honestly I don't use either the buffer-menu or ibuffer that
    much because I have consult installed, which has its consult-buffer
    command that I /love/. It does buffers and recent files (and other
    stuff too, I think, but I just use those).

    Heck yeahh!! TRAMP is amazing.

    For some reason, TRAMP is like, weird for me. I need to do more
    research to make it work.


    What I'm searching is a way to have 2 elpher buffers open at the same
    time... comes time, comes wheel... or such...

    Gosh, I only started really using elpher recently, so I didn't even
    realize it couldn't do this.

    That's quite the functionality gap, huh? (I wonder how hard it would be
    to implement? I know the gopher git service on elpher's homepage has a section for submitted patches, like the one to connect to gemini links
    in tty emacs without erroring out)

    I /think/ that there's a fork that allows multple elpher buffers
    ... hold on (I'm checking) .. yeah there's two on this page:

    gopher://thelambdalab.xyz/1/scripts/browse-git.scm%7Celpher.git

    I haven't tried either, but they're there.

    I'm going to send another message to this thread with the stuff I use.
    I originally meant this reply to just be a response to the elpher thing,
    woops!

    --
    ~ acdw
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Case Duckworth@acdw@acdw.net to tilde.text on Wed Apr 28 11:42:21 2021

    Okay, I hope I didn't mess up posting that other reply. If I did, I apologize... I'm still gnu to gnus (heheheheh).

    Anyway, here's some tricks I use with Emacs. My whole config can be
    found at https://tildegit.org/acdw/emacs.

    1. `when-unfocused'. This lets me garbage collect or auto-save all
    files when all Emacs frames are unfocused.

    (defmacro when-unfocused (name &rest forms)
    "Define a function NAME, executing FORMS, that fires when Emacs
    is unfocused."
    (declare (indent 1))
    (let ((func-name (intern (concat "when-unfocused-" (symbol-name name))))) `(progn
    (defun ,func-name () "Defined by `when-unfocused'."
    (when (seq-every-p #'null
    (mapcar #'frame-focus-state (frame-list)))
    ,@forms))
    (add-function :after after-focus-change-function #',func-name))))

    2. `sunrise-sunset'. I change themes (modus FTW) when the sun comes up
    and goes down. This is what does that. It's adapted from some other
    function somewhere, and made more robust.


    (defun acdw/sunrise-sunset (sunrise-command sunset-command)
    "Run commands at sunrise and sunset."
    (let* ((times-regex (rx (* nonl)
    (: (any ?s ?S) "unrise") " "
    (group (repeat 1 2 digit) ":"
    (repeat 1 2 digit)
    (: (any ?a ?A ?p ?P) (any ?m ?M)))
    (* nonl)
    (: (any ?s ?S) "unset") " "
    (group (repeat 1 2 digit) ":"
    (repeat 1 2 digit)
    (: (any ?a ?A ?p ?P) (any ?m ?M)))
    (* nonl)))
    (ss (sunrise-sunset))
    (_m (string-match times-regex ss))
    (sunrise-time (match-string 1 ss))
    (sunset-time (match-string 2 ss)))
    (run-at-time sunrise-time (* 60 60 24) sunrise-command)
    (run-at-time sunset-time (* 60 60 24) sunset-command)
    (run-at-time "12:00am" (* 60 60 24) sunset-command)))

    3. I changed C-z to make kind of a custom "leader key" ... mostly I use
    it for apps like GNUS (C-z m) or elpher (C-z e), or to toggle debugging
    (C-z d) or kill emacs (C-z C-c).

    That's it for now! Great thread idea, Arch!

    --
    ~ acdw
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 11:14:38 2021
    What I'm searching is a way to have 2 elpher buffers open at the same
    time... comes time, comes wheel... or such...

    Gosh, I only started really using elpher recently, so I didn't even
    realize it couldn't do this.

    That's quite the functionality gap, huh? (I wonder how hard it would be
    to implement? I know the gopher git service on elpher's homepage has a
    section for submitted patches, like the one to connect to gemini links
    in tty emacs without erroring out)

    I /think/ that there's a fork that allows multple elpher buffers
    ... hold on (I'm checking) .. yeah there's two on this page:

    gopher://thelambdalab.xyz/1/scripts/browse-git.scm%7Celpher.git

    I haven't tried either, but they're there.

    Huh! Wouldja look at that, it was right there next to the tty fix, even!

    Thanks for pointing that out! ^^

    I'm going to send another message to this thread with the stuff I use.
    I originally meant this reply to just be a response to the elpher thing, woops!

    Sure! I'll comment on the rest of this there, then~
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 11:15:02 2021
    Case Duckworth <acdw@acdw.net> writes:
    Arch <archenoth@tilde.town> writes:

    It's also nice to be able to M-x auto-revert-mode, since that works in a
    loooot of places that a lot of people don't expect.

    I have (global-auto-revert-mode +1) in my ~/.emacs, and I can confirm,
    it's great. I don't even think about it.

    I mean, my use-case is that I want Emacs and the filesystem to mirror
    each other -- I'm on a single-user system where I know that I don't open
    a file in more than one place at a time (though locks would probably fix that? Anyway...).

    Oh yeah! This is nice on tildes too for watching shared folders,
    especially if you set your dired-listing-switches to include "-t",
    because then new files just jump to the top of the buffer as they are
    edited.


    I copy-pasted the advice to (global-set-key (kbd "C-x C-b") #'ibuffer) a while ago; Honestly I don't use either the buffer-menu or ibuffer that
    much because I have consult installed, which has its consult-buffer
    command that I /love/. It does buffers and recent files (and other
    stuff too, I think, but I just use those).

    Huh. TIL consult


    Heck yeahh!! TRAMP is amazing.

    For some reason, TRAMP is like, weird for me. I need to do more
    research to make it work.

    I find that tab completion really helps TRAMP, since it can be a bit
    finicky sometimes.

    Like, to do /sudo::<path>, I often have to type

    /sudo::/<Tab> (type in my password)

    and then I can type the rest of the path.

    For ssh, I find sshx is the most reliable and fastest method, since it
    holds the connection open the entire time. (You can see it in M-x list-processes)

    Multi-hops are a bit more tricky, like for /sshx:box|docker:container:/
    I have to type

    /sshx:box:/<Tab>

    then I backspace the last colon and type

    /sshx:box|docker:container:/<Tab>

    then I can finally type the rest of my path. And afterwards, Emacs
    handles that path gracefully without needing to do that process again.

    Also, "box" can be "username@box" too, though I usually have that all
    set up nicely in my ~/.ssh/config so I never need to do more than
    mention the box to TRAMP, even when using ProxyJumps to hop between
    multiple hosts first. (Which is considerably faster than stringing sshx connections together in TRAMP itself)

    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 17:17:39 2021
    Case Duckworth <acdw@acdw.net> writes:

    I mean, my use-case is that I want Emacs and the filesystem to mirror
    each other -- I'm on a single-user system where I know that I don't open
    a file in more than one place at a time (though locks would probably fix that? Anyway...).

    I think persistent OSses need more thoughts!

    Why not always have the internal state of processes/buffers on the HD
    and just use a cache to speed it up? Or the other way round? HD as
    default memory, just a bit decoupled by caches. Sure some fat
    capacitors to write back everything in an emergency shutdown situation

    gopher://thelambdalab.xyz/1/scripts/browse-git.scm%7Celpher.git

    Current elpher doesn't even install any more on Debian10's default
    emacs. And I forgot why I went back to 26.1 after trying 27.x from
    backports. That one had some other glitches. I should take much mor
    notes! ***sigh!***

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Case Duckworth@acdw@acdw.net to tilde.text on Wed Apr 28 12:25:14 2021
    Arch <archenoth@tilde.town> writes:

    Arch <archenoth@tilde.town> writes:

    Oh yeah! This is nice on tildes too for watching shared folders,
    especially if you set your dired-listing-switches to include "-t",
    because then new files just jump to the top of the buffer as they are
    edited.

    That '-t' flag is a great idea, thanks :)

    I copy-pasted the advice to (global-set-key (kbd "C-x C-b") #'ibuffer) a
    while ago; Honestly I don't use either the buffer-menu or ibuffer that
    much because I have consult installed, which has its consult-buffer
    command that I /love/. It does buffers and recent files (and other
    stuff too, I think, but I just use those).

    Huh. TIL consult

    OH BOY, consult is awesome. Check it out with `marginalia' too, and
    apparently `embark' really rounds out the trio --- but I haven't used
    the last one. They take the ideas of helm/ivy and make them more
    in-line with Emacs primitives, so you can kind of split out whatever you
    want and it'll work. Right now I'm using them with vertico for the
    minibuffer, but you can use icomplete, ido, icomplete-vertical,
    selectrum, ...

    For ssh, I find sshx is the most reliable and fastest method, since it
    holds the connection open the entire time. (You can see it in M-x list-processes)

    Multi-hops are a bit more tricky, like for /sshx:box|docker:container:/
    I have to type

    /sshx:box:/<Tab>

    then I backspace the last colon and type

    /sshx:box|docker:container:/<Tab>

    then I can finally type the rest of my path. And afterwards, Emacs
    handles that path gracefully without needing to do that process again.

    For some reason, I don't get /ssh: as an option /at all/ when trying to complete file paths. Maybe it still /is/ possible, but I just have to
    type it ... ? Same with SUDO. Like, Tramp isn't working..

    Honestly, I need to check when I get home (and can actually use Tramp;
    I'm on Windows rn at work :/)

    --
    ~ acdw
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.text on Wed Apr 28 17:36:56 2021
    Arch <archenoth@tilde.town> writes:

    I find that tab completion really helps TRAMP, since it can be a bit
    finicky sometimes.

    I switched something in tramp's TAB behaviour to stop on partial matches
    like the other shells and not to skip '..'.

    | (custom-set-variables
    | ...
    | '(eshell-cmpl-cycle-completions nil)
    | '(eshell-cmpl-dir-ignore "\\`\\(CVS\\)/\\'")
    | ...
    | '(eshell-prompt-regexp "^[^$
    | ]* [$] ")
    ^
    !!!mean "\n" inside!!!

    The last one was needed to allow paths with "#", which I sometimes need
    when "ssh -p SOMEPORT"-ing to e.g. qemu-VMs.

    --
    Take Back Control! — Mesh The Planet!
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Wed Apr 28 17:44:03 2021
    Case Duckworth <acdw@acdw.net> writes:

    Okay, I hope I didn't mess up posting that other reply. If I did, I apologize... I'm still gnu to gnus (heheheheh).

    Hee, that's a mood.

    Anyway, here's some tricks I use with Emacs. My whole config can be
    found at https://tildegit.org/acdw/emacs.

    1. `when-unfocused'. This lets me garbage collect or auto-save all
    files when all Emacs frames are unfocused.

    (defmacro when-unfocused (name &rest forms)
    "Define a function NAME, executing FORMS, that fires when Emacs
    is unfocused."
    (declare (indent 1))
    (let ((func-name (intern (concat "when-unfocused-" (symbol-name name))))) `(progn
    (defun ,func-name () "Defined by `when-unfocused'."
    (when (seq-every-p #'null
    (mapcar #'frame-focus-state (frame-list)))
    ,@forms))
    (add-function :after after-focus-change-function #',func-name))))

    I've never really used the focus of windows in any meaningful way.

    This looks like it could be handy for doing all sorts of maintenence
    tasks though! Nice snippet~


    2. `sunrise-sunset'. I change themes (modus FTW) when the sun comes up
    and goes down. This is what does that. It's adapted from some other function somewhere, and made more robust.


    (defun acdw/sunrise-sunset (sunrise-command sunset-command)
    "Run commands at sunrise and sunset."
    (let* ((times-regex (rx (* nonl)
    (: (any ?s ?S) "unrise") " "
    (group (repeat 1 2 digit) ":"
    (repeat 1 2 digit)
    (: (any ?a ?A ?p ?P) (any ?m ?M)))
    (* nonl)
    (: (any ?s ?S) "unset") " "
    (group (repeat 1 2 digit) ":"
    (repeat 1 2 digit)
    (: (any ?a ?A ?p ?P) (any ?m ?M)))
    (* nonl)))
    (ss (sunrise-sunset))
    (_m (string-match times-regex ss))
    (sunrise-time (match-string 1 ss))
    (sunset-time (match-string 2 ss)))
    (run-at-time sunrise-time (* 60 60 24) sunrise-command)
    (run-at-time sunset-time (* 60 60 24) sunset-command)
    (run-at-time "12:00am" (* 60 60 24) sunset-command)))

    Oh! A little theme-based night mode. That's pretty cute, hee.
    Modus has some pretty neat goals too~

    3. I changed C-z to make kind of a custom "leader key" ... mostly I use
    it for apps like GNUS (C-z m) or elpher (C-z e), or to toggle debugging
    (C-z d) or kill emacs (C-z C-c).


    That's it for now! Great thread idea, Arch!

    Aww, thank you!

    I kinda wanted to drum up a little activity here, plus I'm always
    curious about the ways others use the things they like~
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Tue May 4 00:43:47 2021
    Another trick is how to interact with Emacs when it's completely frozen.

    If you send a -USR2 signal with kill to a frozen emacs, it will stop
    whatever it's doing and drop you into a debugger. This often works
    *even* if it was stuck so hard that mashing C-g isn't getting you
    anywhere.

    That way you can save your session and also see exactly where it froze
    in the stack trace, that way, not only can you recover; you can also see
    what *caused* you to need to recover. That means you can know how to fix
    or avoid it for later.

    (One thing to note is that it also toggles debug on quit, so you'll need
    to run M-x toggle-debug-on-quit to stop C-g from dropping you to a
    debugger every time you hit it after you've recovered)
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Tue May 4 21:49:06 2021
    Another few simple ones are:

    - When searching with C-s or C-r, you can use C-w to pull in the word
    immediately after point, and you can repeat this for as many words you
    like. That means you don't need to copy things at point to search them

    - You can tab complete things like M-x with the Space bar--which is
    extremely handy if you are using Emacs in an environment like Termux
    or something else where the tab key is harder to access

    - Not a lot of people realize you can use C-j in the default scratch
    buffer to evaluate Lisp forms before your point (Like C-x C-e) and
    spit out the result on the next line. This can be a lot more
    convenient if you want to do something with the result since it
    doesn't need to be excavated from the Messages buffer.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Neodium@neo@neo.tld to tilde.text on Thu Aug 5 11:25:14 2021
    yeti <yeti@tilde.institute> writes:

    Arch <archenoth@tilde.town> writes:

    What kind of tricks do you all have for Emacs?

    I've bound...

    (global-set-key [f12] 'buffer-menu)

    ...to pop of the whole buffer list.

    I highly recommend using the built-in bs-show instead of buffer-menu.
    bs-show hides automatic buffers which can be toggled using 'a'.
    it is also much more customizable though i think the defaults are
    already great.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Arch@archenoth@tilde.town to tilde.text on Sat Aug 7 01:02:04 2021
    Oh wow, TIL bs-show.

    I've mostly heard people talk about ibuffer as a built-in alternative,
    but I think this is the first I've ever seen this one
    --- Synchronet 3.19a-Linux NewsLink 1.113