Add functions to insert images using SXIV
This commit is contained in:
parent
3d44b11d14
commit
c96ad07219
@ -1698,6 +1698,45 @@ Insert Image that is in the figs folder
|
||||
(insert (format "[[file:%s]]" img)))
|
||||
#+end_src
|
||||
|
||||
Insert Image that is in the =figs= folder using SXIV
|
||||
#+begin_src emacs-lisp
|
||||
(defun tdh-insert-image-org-link-sxiv ()
|
||||
"Insert an org image link, choosing the file with completion
|
||||
and starting from `my-default-image-directory'."
|
||||
(interactive)
|
||||
(setq img (shell-command-to-string "ls figs/*.{jpg,jpeg,bmp,png,gif} 2> /dev/null | sxiv -i -t -o | tail -1 | tr -d '\n'"))
|
||||
(unless (equal "" img)
|
||||
(insert (format "[[file:%s]]" img)))
|
||||
)
|
||||
#+end_src
|
||||
|
||||
Copy picture from phone folder using SXIV and insert it
|
||||
#+begin_src emacs-lisp
|
||||
(defun tdh-insert-phone-picture ()
|
||||
(interactive)
|
||||
(setq img (shell-command-to-string "~/.config/doom/bin/copy-phone-picture.sh"))
|
||||
(unless (equal "" img)
|
||||
(insert (format "[[file:%s]]" img)))
|
||||
)
|
||||
#+end_src
|
||||
|
||||
Bash script for copying pictures taken by phone.
|
||||
#+begin_src bash :comments both :mkdirp yes :shebang "#!/usr/bin/env bash" :tangle ~/.config/doom/bin/copy-phone-picture.sh
|
||||
if [ -z "$1" ]; then
|
||||
oldpath=$(ls -t ~/Cloud/photos/phone/*.jpg | sxiv -i -t -o | tail -1);
|
||||
else
|
||||
oldpath=$(ls -t $1 | sxiv -i -t -o | tail -1);
|
||||
fi
|
||||
|
||||
if [ -n "$oldpath" ]; then
|
||||
newfilename=$(basename $oldpath .jpg | rofi -i -dmenu -p "Filename")
|
||||
if [ -n "$newfilename" ]; then
|
||||
cp $oldpath "figs/$newfilename.jpg"
|
||||
printf "figs/$newfilename.jpg"
|
||||
fi
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
Take Screenshot and insert a link:
|
||||
- Ask for a name =screenshot_name=
|
||||
- use =maim -s figs/screenshot_name.png= to take a screenshot with selection
|
||||
@ -1722,6 +1761,8 @@ Map Keys
|
||||
:n "p" 'tdh-insert-paper-org-link
|
||||
:n "n" 'tdh-insert-note-org-link
|
||||
:n "f" 'tdh-insert-image-org-link
|
||||
:n "F" 'tdh-insert-image-org-link-sxiv
|
||||
:n "i" 'tdh-insert-phone-picture
|
||||
:n "s" 'tdh-insert-screenshot-org-link)))
|
||||
#+end_src
|
||||
|
||||
@ -2127,6 +2168,28 @@ This function:
|
||||
:n "<C-S-return>" #'tdh-ctrl-shift-ret)
|
||||
#+end_src
|
||||
|
||||
** Align Source Blocks
|
||||
#+begin_src emacs-lisp
|
||||
(defun tdh-align-src-block ()
|
||||
(interactive)
|
||||
(defun in-src-block-p ()
|
||||
"Returns t when the point is inside a source code block"
|
||||
(string= "src" (org-in-block-p '("src"))))
|
||||
|
||||
(if (in-src-block-p)
|
||||
(progn
|
||||
(org-edit-special)
|
||||
(evil-indent (point-min) (point-max))
|
||||
(org-edit-src-exit))
|
||||
(org-table-eval-formula)))
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(map! :after evil-org
|
||||
:map evil-org-mode-map
|
||||
:n "C-c =" #'tdh-align-src-block)
|
||||
#+end_src
|
||||
|
||||
** Helping Functions - Tangling =,b=
|
||||
Org-Babel Tangle Sub-tree
|
||||
#+begin_src emacs-lisp
|
||||
@ -2142,7 +2205,7 @@ Org-Babel Tangle Sub-tree
|
||||
|
||||
Org-Tangle and Org-Babel Jump to Tangle File
|
||||
#+begin_src emacs-lisp
|
||||
(defun tdh-org-babel-jump-to-tangle-file ()
|
||||
(defun tdh-org-babel-jump-to-tangle-file ()
|
||||
"Jump to tangle file for the source block at point."
|
||||
(interactive)
|
||||
(let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
|
||||
|
Loading…
Reference in New Issue
Block a user