Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on reddit.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/reddit.e>
#           or at <http://angg.twu.net/e/reddit.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######



# «.ace-window»			(to "ace-window")
# «.ace-window-long»		(to "ace-window-long")
# «.ace-window-defun-q2»	(to "ace-window-defun-q2")



https://www.reddit.com/r/emacs/
https://www.reddit.com/user/edrx/
https://www.reddit.com/r/emacs/comments/g89q2y/learning_elisp_need_some_help/fotdo8n/

Just to complement what other people have already said, I find it
helpful to keep tests in comments, like this:

    (defun a-plus-abs-b (a b)
      (funcall (if (> b 0) '+ '-) a b))
    
    ;; Tests (use C-e C-x C-e to eval each one):
    ;;
    ;; (setq a  3)
    ;; (setq b  42)
    ;; (setq b -42)
    ;; (> b 0)
    ;; (if (> b 0) '+ '-)
    ;; (funcall (if (> b 0) '+ '-) a b)
    ;; (a-plus-abs-b 3 42)
    ;; (a-plus-abs-b 3 -42)
    ;;
    ;; For more information:
    ;; (info "(elisp)Calling Functions")




#####
#
# Share Your 'other-window' Commands
# 2022oct21
#
#####

# «ace-window»  (to ".ace-window")
# https://www.reddit.com/r/emacs/comments/x0r0pe/comment/in9ngqj/?context=3



#####
#
# ace-window-long
# 2022oct21
#
#####

# «ace-window-long»  (to ".ace-window-long")
# https://lists.gnu.org/archive/html/eev/2022-09/msg00000.html my long answer

Hi Arthurno1!

Sorry if my comment was too brief - I thought something like "I will
expand it if someone finds it interesting". So let me expand it
now!...

Let me start with the multiwindow functions. I will try to answer your
"execute command in 'other-buffer'" after that.

The functions in
<http://angg.twu.net/eev-current/eev-multiwindow.el.html> are my
favorite basic building blocks for writing multiwindow functions. They
work well for me because I have very quick ways to generate elisp
hyperlinks to files and other kinds of buffers... for example, this
the function that I use to create a 3-window layout with a directory
of directory of photos of whiteboards ("quadros") at the left, a
makefile at the top right, and another makefile at the bottom right:

  (defun q2 () (interactive)
    (find-3a '(find-fline "~/2022.2-quadros/")
             '(find-fline "~/2022.2-C2/Makefile")
             '(find-fline "~/2022.2-C3/Makefile")))

I was able to write it very quickly because I used my functions to
create "hyperlinks to here" to generate the three "find-fline" sexps.
So: I visited the directory "~/2022.2-quadros/" and generated an elisp
hyperlink to that, then visited the first makefile and generated
another elisp hyperlink to that, then did the same for the second
makefile - and I copied those three hyperlinks to my notes.

If I precede a sexp hyperlink - obs: this only works well for
one-liners - by a function name, like this,

  q0 (find-fline "~/2022.2-quadros/")

and I type M-J then that line is converted to this:

  (defun q0 () (interactive) (find-fline "~/2022.2-quadros/"))

so defining a function with a very short name that opens a file or a
directory in the current window is something that takes only a few
keystrokes to me (but WARNING! Some people have told me that they find
the mechanism for generating "hyperlinks to here" quite clumsy to
use... I've worked a lot to make it easier to use, but I'm only
halfway there at best =(... I'll try to watch some videos on
ace-window after finishing this answer to see if it has ideas that I
borrow/steal. Any recommendations?)

Anyway, let me go back. So: producing the (defun q0 ...) above is
"trivial" in terms of number of keystrokes and things to remember, at
least if the person doing that is me... producing the (defun q2 ...)
further above - the one that is four lines long - not so much, I had
to write most of the stuff around the find-flines by hand. That
function q2 is not as fragile as it seems - this tutorial here

  http://angg.twu.net/eev-intros/find-multiwindow-intro.html

start by explaining that

  (find-3a '(find-fline "~/2022.2-quadros/")
           '(find-fline "~/2022.2-C2/Makefile")
           '(find-fline "~/2022.2-C3/Makefile"))

is equivalent to

  (find-wset "13_o2_o_o"
             '(find-fline "~/2022.2-quadros/")
             '(find-fline "~/2022.2-C2/Makefile")
             '(find-fline "~/2022.2-C3/Makefile"))

and that that is sort of equivalent to this,

  (progn (eek "C-x 1 C-x 3")
         (find-fline "~/2022.2-quadros/")
         (eek "C-x o C-x 2")
         (find-fline "~/2022.2-C2/Makefile")
         (eek "C-x o")
         (find-fline "~/2022.2-C3/Makefile")
         (eek "C-x o"))

but actually the find-wset above is equivalent to this:

  (progn (find-wset-1)
         (find-wset-3)
         (find-fline "~/2022.2-quadros/")
         (find-wset-o)
         (find-wset-2)
         (find-fline "~/2022.2-C2/Makefile")
         (find-wset-o)
         (find-fline "~/2022.2-C3/Makefile")
         (find-wset-o))

where find-wset-1, ..., find-wset-o are defined as:

  (defun find-wset-1 () (delete-other-windows))
  (defun find-wset-2 () (split-window-vertically))
  (defun find-wset-3 () (split-window-horizontally))
  (defun find-wset-o () (other-window 1))

Now let me try to answer your "execute command in 'other-buffer'". I
am not sure if I understood it correctly, so I'll answer the first
interpretation of your question that came to my mind...

I have always found very annoying that many functions in Emacs opened
a second window, or even a second frame, following defaults and
heuristics that were scattered through many variables, and that I was
never able to understand very well... so one thing that I did - ages
ago! - was to create variants of those functions that would always
show their buffers in the current window. For example,

  (man "1 cat")

is badly behaved - it uses a second window or a new frame - but

  (find-man "1 cat")

uses the current window, and is "refinable", in the sense that I can
add extra arguments meaning "search for this string"... for example:

  (find-man "1 cat" "-s, --squeeze-blank")

I usually follow elisp hyperlinks like the one above with just M-e,
that shows the target buffer in the current window, but if I follow it
with M-2 M-e then this will work as:

  (find-2a nil '(find-man "1 cat" "-s, --squeeze-blank"))

that splits the frame in two windows, opens the manpage in the window
at the right, and stays at the window at the left, and if I follow it
with M-3 M-e this will work as:

  (find-2b nil '(find-man "1 cat" "-s, --squeeze-blank"))

that does the same, but goes to the window at the right...

So: I interpreted your "other buffer" as "other window", and I
explained how I execute commands both "in the same window" and "at the
window at the right"... btw, most of my functions that make
badly-behaved functions use "the same window" use this wrapper
function:

  http://angg.twu.net/eev-current/eev-blinks.el.html#find-dbsw

Anyway, I am watching this video now,

  Switching Emacs windows with hydra and ace-window
  https://www.youtube.com/watch?v=_qZliI1BKzI

by abo-abo himself, and it looks AMAZING!!! I will try to learn how to
use it - and I think that for most people ace-window is more
convenient, and makes more sense, than my tricks for creating
functions with very short names that open certain files...

Anyway 2: hey, I am just a weirdo who finds one-liners in elisp much
more fun to play with than keybindings, and who got addicted to a
certain way of building new one-liners from old ones, and who hangs
out on IRC a lot!... If there are any parts of eev that look
interesting to you but that you don't know how to use conveniently -
i.e.: their workflows are a mystery - please get in touch, let's see
if we can solve that by chatting on #emacs! And until that happens
I'll try to see if I can learn ace-window...

Btw, the four defuns in your original question look very good to me! I
thought a bit on how I would write them using find-wset, and I think
that the "right way" to do that in (my) eev style would be by defining
a function find-wset-A... like this:

  (defun find-wset-A () (if (one-window-p) (split-window-horizontally)))
  (defun find-2A (b) (find-wset "Ao_O" b))
  ;; Test: (find-2A '(eek "<down>"))

Would you like me to try to translate your four defuns into that
style?

  Best =),
    E.





#####
#
# ace-window-defun-q2
# 2022oct21
#
#####

# «ace-window-defun-q2»  (to ".ace-window-defun-q2")

You have some good points. I think that I need to stress in the docs
that the workflow that I described is only worth the pain when we
really, really, REALLY want to keep "executable notes" of how to
obtain a certain window configuration... I prefer this

  (defun q2 () (interactive)
      (find-3a '(find-fline "~/2022.2-quadros/")
               '(find-fline "~/2022.2-C2/Makefile")
               '(find-fline "~/2022.2-C3/Makefile")))

to a macro because it is easier to read, easier to edit, and easier to
adapt to other tasks than a macro. I have a bunch of things like this

  (setq last-kbd-macro (kbd "M-h M-2 (find-fline SPC \" 2*<delete>
    M-z : C-y <left> \" <delete> SPC\n M-z : C-y DEL SPC \" <delete>
    M-z = C-y 3*<left> C-k \") C-a <down> RET"))

saved in my notes, but usually they become hard to read very
quickly... while the function q2 above is something that I know that I
will have to execute hundreds of times in 2022.2 (an academic
semester) with M-x q2, and that when 2022.2 ends and 2023.1 start I
will just have to modify it a bit... but most people would prefer to do
that by using something like ace-window than by writing small programs
in Lisp.

  [[]] =/,
    E.







https://www.reddit.com/r/emacs/comments/kkaqyj/some_templatebased_functions_of_eev_that_are_not/

https://karl-voit.at/2020/10/23/avoid-web-forums/
https://en.wikipedia.org/wiki/Vendor_lock-in




#  Local Variables:
#  coding:               utf-8-unix
#  End: