[Org Files] Better readable Elisp code
This commit is contained in:
		
							parent
							
								
									124644ff3c
								
							
						
					
					
						commit
						deb3e03877
					
				@ -150,7 +150,7 @@ config file in order to modify which terminal or text editor I use, not that I
 | 
				
			|||||||
do it often though.
 | 
					do it often though.
 | 
				
			||||||
#+BEGIN_SRC lua
 | 
					#+BEGIN_SRC lua
 | 
				
			||||||
  terminal = "kitty"
 | 
					  terminal = "kitty"
 | 
				
			||||||
  editor = os.getenv("EDITOR") or "emacsclient -c"
 | 
					  editor = os.getenv("EDITOR") or "emacsclient -c -a emacs"
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
** Keys
 | 
					** Keys
 | 
				
			||||||
@ -353,17 +353,20 @@ them, and their order in the table is their order in Awesome.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#+NAME: list-layouts
 | 
					#+NAME: list-layouts
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var layouts=table-layouts :cache yes
 | 
					#+BEGIN_SRC emacs-lisp :var layouts=table-layouts :cache yes
 | 
				
			||||||
  (mapconcat (lambda (x) (if (string= (cadr x) "yes")
 | 
					  (mapconcat (lambda (layout)
 | 
				
			||||||
                             (format "awful.layout.suit.%s,\n" (car x))))
 | 
					               (let ((enabled-p (string= (cadr layout) "yes"))
 | 
				
			||||||
 | 
					                     (layout    (car layout)))
 | 
				
			||||||
 | 
					                (when enabled-p
 | 
				
			||||||
 | 
					                    (format "awful.layout.suit.%s,\n" layout))))
 | 
				
			||||||
             layouts
 | 
					             layouts
 | 
				
			||||||
             "")
 | 
					             "")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS[0bd0312ff10526c8b24199453ff235cf71425fb5]: list-layouts
 | 
					#+RESULTS[bf3bbbd40ecc04ec19d9660abff2080b4f68196a]: list-layouts
 | 
				
			||||||
#+begin_example
 | 
					#+begin_example
 | 
				
			||||||
awful.layout.suit.magnifier,
 | 
					awful.layout.suit.magnifier,
 | 
				
			||||||
awful.layout.suit.tile,
 | 
					 | 
				
			||||||
awful.layout.suit.tile.left,
 | 
					awful.layout.suit.tile.left,
 | 
				
			||||||
 | 
					awful.layout.suit.tile,
 | 
				
			||||||
awful.layout.suit.tile.bottom,
 | 
					awful.layout.suit.tile.bottom,
 | 
				
			||||||
awful.layout.suit.tile.top,
 | 
					awful.layout.suit.tile.top,
 | 
				
			||||||
awful.layout.suit.max,
 | 
					awful.layout.suit.max,
 | 
				
			||||||
@ -395,22 +398,18 @@ below.
 | 
				
			|||||||
:CUSTOM_ID: Top_bar-Menus-cf468ca8
 | 
					:CUSTOM_ID: Top_bar-Menus-cf468ca8
 | 
				
			||||||
:END:
 | 
					:END:
 | 
				
			||||||
#+NAME: make-menu
 | 
					#+NAME: make-menu
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var menu=table-awesome-menu
 | 
					#+BEGIN_SRC emacs-lisp :var menu=table-main-menu
 | 
				
			||||||
  (mapconcat (lambda (x)
 | 
					  (mapconcat (lambda (item)
 | 
				
			||||||
               (format "{ \"%s\", %s }"
 | 
					               (format "{ \"%s\", %s }"
 | 
				
			||||||
                       (car x)
 | 
					                       (car item)
 | 
				
			||||||
                       (mapconcat (lambda (y) (format "%s" y))
 | 
					                       (mapconcat #'identity (cdr item) ", ")))
 | 
				
			||||||
                                  (cdr x)
 | 
					 | 
				
			||||||
                                  ",")))
 | 
					 | 
				
			||||||
             menu
 | 
					             menu
 | 
				
			||||||
             ",\n")
 | 
					             ",\n")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS: make-menu
 | 
					#+RESULTS: make-menu
 | 
				
			||||||
: { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }
 | 
					: { "awesome", awesomewm_menu, beautiful.awesome_icon },
 | 
				
			||||||
: { "edit config", editor .. " " .. awesome.conffile }
 | 
					: { "open terminal", terminal, nil }
 | 
				
			||||||
: { "restart", awesome.restart }
 | 
					 | 
				
			||||||
: { "quit", function() awesome.quit() end }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
It is possible to create actual menus in Awesome, including the one available at
 | 
					It is possible to create actual menus in Awesome, including the one available at
 | 
				
			||||||
the top-left corner of the screen. First, let’s declare a menu related to
 | 
					the top-left corner of the screen. First, let’s declare a menu related to
 | 
				
			||||||
@ -847,16 +846,17 @@ Here is a description of the tables displayed below:
 | 
				
			|||||||
      (format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})"
 | 
					      (format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})"
 | 
				
			||||||
              modifiers
 | 
					              modifiers
 | 
				
			||||||
              key
 | 
					              key
 | 
				
			||||||
              (pcase lambda-p
 | 
					              (if (not lambda-p)
 | 
				
			||||||
                ('lambda
 | 
					                  action
 | 
				
			||||||
                 (format "function(%s) %s end" clientkey action))
 | 
					                (format "function(%s) %s end" clientkey
 | 
				
			||||||
                ('shell
 | 
					                        (pcase lambda-p
 | 
				
			||||||
                 (format "function(%s) awful.spawn.with_shell(\"%s\") end" clientkey action))
 | 
					                          ('lambda action)
 | 
				
			||||||
                ('terminal
 | 
					                          ('shell
 | 
				
			||||||
                 (format "function(%s) awful.spawn(terminal..\" -e %s\" end" clientkey action))
 | 
					                           (format "awful.spawn.with_shell(\"%s\")" action))
 | 
				
			||||||
                ('spawn
 | 
					                          ('terminal
 | 
				
			||||||
                 (format "function(%s) awful.spawn(\"%s\") end" clientkey action))
 | 
					                           (format "awful.spawn(terminal..\" -e %s\")" action))
 | 
				
			||||||
                (otherwise action))
 | 
					                          ('spawn
 | 
				
			||||||
 | 
					                           (format "awful.spawn(\"%s\")" action)))))
 | 
				
			||||||
              description
 | 
					              description
 | 
				
			||||||
              group)))
 | 
					              group)))
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
@ -867,8 +867,8 @@ Here is a description of the tables displayed below:
 | 
				
			|||||||
   <<gen-sc-text>>
 | 
					   <<gen-sc-text>>
 | 
				
			||||||
   (seq-filter (lambda (x)
 | 
					   (seq-filter (lambda (x)
 | 
				
			||||||
                 (let ((clientkey-p (nth 6 x)))
 | 
					                 (let ((clientkey-p (nth 6 x)))
 | 
				
			||||||
                     (or (not (nth 6 x))
 | 
					                     (or (not clientkey-p)
 | 
				
			||||||
                         (string= "no" (nth 6 x)))))
 | 
					                         (string= "no" clientkey-p))))
 | 
				
			||||||
               table)
 | 
					               table)
 | 
				
			||||||
   ",\n")
 | 
					   ",\n")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
@ -877,38 +877,14 @@ Here is a description of the tables displayed below:
 | 
				
			|||||||
#+BEGIN_SRC emacs-lisp :var table=sc-client :cache yes
 | 
					#+BEGIN_SRC emacs-lisp :var table=sc-client :cache yes
 | 
				
			||||||
  (mapconcat
 | 
					  (mapconcat
 | 
				
			||||||
   <<gen-sc-text>>
 | 
					   <<gen-sc-text>>
 | 
				
			||||||
   (seq-filter (lambda (x)
 | 
					   (seq-filter (lambda (keybind)
 | 
				
			||||||
                 (string= "yes" (nth 6 x)))
 | 
					                 (string= "yes" (nth 6 keybind)))
 | 
				
			||||||
               table)
 | 
					               table)
 | 
				
			||||||
   ",\n")
 | 
					   ",\n")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS[5a0293b89fe106cb2b71ba10d9548b29aa2f9543]: gen-sc-client
 | 
					 | 
				
			||||||
#+begin_example
 | 
					 | 
				
			||||||
awful.key({modkey},"f",function(c) toggle_fullscreen_client(c) end,
 | 
					 | 
				
			||||||
  {description="toggle fullscreen",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey},"m",function(c) toggle_maximized(c) end,
 | 
					 | 
				
			||||||
  {description="toggle maximized",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey, control},"m",function(c) toggle_vertical_maximized(c) end,
 | 
					 | 
				
			||||||
  {description="toggle vertically maximized",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey, shift},"m",function(c) toggle_horizontal_maximized(c) end,
 | 
					 | 
				
			||||||
  {description="toggle horizontally maximized",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey, shift},"n",function(c) c.minimized = true end,
 | 
					 | 
				
			||||||
  {description="minimize",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey},"o",function(c) c:move_to_screen() end,
 | 
					 | 
				
			||||||
  {description="move to screen",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey},"q",function(c) c:kill() end,
 | 
					 | 
				
			||||||
  {description="close client",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey},"v",function(c) c.ontop = not c.ontop end,
 | 
					 | 
				
			||||||
  {description="toggle keep on top",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey, control},"space",awful.client.floating.toggle,
 | 
					 | 
				
			||||||
  {description="toggle floating",group="client"}),
 | 
					 | 
				
			||||||
awful.key({modkey, control},"Return",function(c) c:swap(awful.client.getmaster()) end,
 | 
					 | 
				
			||||||
  {description="move to master",group="client"})
 | 
					 | 
				
			||||||
#+end_example
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#+NAME: sc-tag-num-gen
 | 
					#+NAME: sc-tag-num-gen
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var input=sc-tag-num :results drawer
 | 
					#+BEGIN_SRC emacs-lisp :var input=sc-tag-num :results drawer :wrap src lua
 | 
				
			||||||
  (let (result)
 | 
					  (let (result)
 | 
				
			||||||
    (dotimes (i 10 result)
 | 
					    (dotimes (i 10 result)
 | 
				
			||||||
      (let* ((j (+ 1 i)))
 | 
					      (let* ((j (+ 1 i)))
 | 
				
			||||||
 | 
				
			|||||||
@ -706,10 +706,10 @@ working.
 | 
				
			|||||||
#+NAME: python-packages-gen
 | 
					#+NAME: python-packages-gen
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var packages=python-packages-table[,0]
 | 
					#+BEGIN_SRC emacs-lisp :var packages=python-packages-table[,0]
 | 
				
			||||||
  (format "pip install --user %s"
 | 
					  (format "pip install --user %s"
 | 
				
			||||||
          (s-join " " packages))
 | 
					          (string-join packages " "))
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS[cb6abaea9d7130a67569af2b4d1a545651bf29ab]: python-packages-gen
 | 
					#+RESULTS[29652be1076ffac01e34189067efa8fe9abda9d9]: python-packages-gen
 | 
				
			||||||
: pip install --user python-language-server[all] pyls-isort pyls-mypy pyls-black
 | 
					: pip install --user python-language-server[all] pyls-isort pyls-mypy pyls-black
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Let’s install them locally for our user.
 | 
					Let’s install them locally for our user.
 | 
				
			||||||
 | 
				
			|||||||
@ -233,17 +233,17 @@ my own executables, and some more.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#+NAME: generate-extra-paths
 | 
					#+NAME: generate-extra-paths
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var paths=extra-paths[,0] :exports none :cache yes
 | 
					#+BEGIN_SRC emacs-lisp :var paths=extra-paths[,0] :exports none :cache yes
 | 
				
			||||||
  (mapconcat (lambda (x) x)
 | 
					  (mapconcat #'identity
 | 
				
			||||||
             paths " \\\n")
 | 
					             paths " \\\n")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS[8b780f78d3d321222408ba76c754c920d95b03ac]: generate-extra-paths
 | 
					#+RESULTS[3fd24377f29513d4c7edcd9621d0462665efb403]: generate-extra-paths
 | 
				
			||||||
: $HOME/.pub-cache/bin \
 | 
					: $HOME/.pub-cache/bin \
 | 
				
			||||||
:       $HOME/.local/bin \
 | 
					: $HOME/.local/bin \
 | 
				
			||||||
:       $HOME/go/bin \
 | 
					: $HOME/go/bin \
 | 
				
			||||||
:       $HOME/.cargo/bin \
 | 
					: $HOME/.cargo/bin \
 | 
				
			||||||
:       $HOME/.gem/ruby/2.6.0/bin \
 | 
					: $HOME/.gem/ruby/2.6.0/bin \
 | 
				
			||||||
:       $HOME/.cabal/bin
 | 
					: $HOME/.cabal/bin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
So, let’s set our user paths:
 | 
					So, let’s set our user paths:
 | 
				
			||||||
#+BEGIN_SRC fish :noweb yes
 | 
					#+BEGIN_SRC fish :noweb yes
 | 
				
			||||||
 | 
				
			|||||||
@ -59,23 +59,24 @@ interesting information; ~info "Memory" memory~ will look like
 | 
				
			|||||||
#+NAME: info-elements-gen
 | 
					#+NAME: info-elements-gen
 | 
				
			||||||
#+BEGIN_SRC emacs-lisp :var table=info-elements-table :cache yes
 | 
					#+BEGIN_SRC emacs-lisp :var table=info-elements-table :cache yes
 | 
				
			||||||
  (mapconcat (lambda (x)
 | 
					  (mapconcat (lambda (x)
 | 
				
			||||||
               (format "info %s%s"
 | 
					               (let ((prefix      (car x))
 | 
				
			||||||
                       (if (not (string= (car x) ""))
 | 
					                     (information (cadr x)))
 | 
				
			||||||
                           (format "\"%s\" " (car x))
 | 
					                (format "info %s%s"
 | 
				
			||||||
                         "")
 | 
					                        (if (not (string= prefix ""))
 | 
				
			||||||
                       (cadr x)))
 | 
					                            (format "\"%s\" " prefix)
 | 
				
			||||||
 | 
					                          "")
 | 
				
			||||||
 | 
					                        information)))
 | 
				
			||||||
             table
 | 
					             table
 | 
				
			||||||
             "\n")
 | 
					             "\n")
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#+RESULTS[1e66bf48472ad24006f0cb9dc9c86078764ba84e]: info-elements-gen
 | 
					#+RESULTS[83eb4aaa554df955ad996157d911eec3a9251628]: info-elements-gen
 | 
				
			||||||
#+begin_example
 | 
					#+begin_example
 | 
				
			||||||
info line_break
 | 
					 | 
				
			||||||
info title
 | 
					info title
 | 
				
			||||||
info line_break
 | 
					info line_break
 | 
				
			||||||
info cols
 | 
					info cols
 | 
				
			||||||
info line_break
 | 
					info line_break
 | 
				
			||||||
info "OS" distro
 | 
					info "Distro" distro
 | 
				
			||||||
info "Kernel" kernel
 | 
					info "Kernel" kernel
 | 
				
			||||||
info "Uptime" uptime
 | 
					info "Uptime" uptime
 | 
				
			||||||
info "Packages" packages
 | 
					info "Packages" packages
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user