add views to tab bar and into menu and dashboard and move view functions to own file

add commentary function for org-mode with list function to create strings
This commit is contained in:
2021-01-27 01:57:52 +01:00
parent 15ee156a36
commit d8336fbbae
7 changed files with 831 additions and 119 deletions

View File

@@ -24,6 +24,10 @@
:prefix "my-"
:group 'emacs)
(defun my-eval-string (string)
"Evaluate elisp code stored in a string."
(eval (car (read-from-string (format "(progn %s)" string)))))
(defun my-list-delete (element list)
"Destructive version of `delete'.
LIST will be nil if the last ELEMENT was deleted.
@@ -36,6 +40,21 @@ Example:
(my-list-delete '(\"a\") 'my-list)"
(set list (delete element (symbol-value list))))
(defun my-list-to-org-table (lst)
"Convert list into an Org table."
(let ((lines lst)
(rows)
(tbl))
(while lines
(setq rows (car lines))
(setq tbl (concat tbl "|"))
(while rows
(setq tbl (concat tbl (format "%s|" (car rows))))
(setq rows (cdr rows)))
(setq tbl (concat tbl "\n"))
(setq lines (cdr lines)))
tbl))
(defmacro my-plist-put (plist &rest args)
"Example usage:
(my-plist-put my-org-table-colored-cells 'table-name '(\"@23$3\" \"blue\"))
@@ -397,114 +416,5 @@ Usage:
) ;; with-eval-after-load 'org
(defun my-view-python ()
"Three windows.
On the right side a *Anaconda* buffer with optionally
`virtual-auto-fill-mode' active and a *Python* buffer."
(interactive)
(require 'python)
(unless (get-buffer (concat "*" python-shell-buffer-name "*"))
(run-python) ;; cursor is now inside the python buffer.
(other-window -1)
)
(delete-other-windows)
(split-window-horizontally (truncate (* 0.6 (window-body-width))))
(other-window 1)
(switch-to-buffer (concat "*" python-shell-buffer-name "*"))
(split-window-vertically) ;; both are python buffers now.
(switch-to-buffer "*Anaconda*")
(when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
(other-window -1)
)
(defun my-view-elisp ()
"Two windows side-by-side.
On the right side a *Help* buffer with optionally
`virtual-auto-fill-mode' active."
(interactive)
(delete-other-windows)
(split-window-horizontally (truncate (* 0.6 (window-body-width))))
(other-window 1)
(switch-to-buffer "*Help*")
(other-window -1)
)
(defun my-view-shell ()
"Two windows side-by-side.
On the right side a *compilation* buffer.
Use `compile' with `sh <foo.sh -flag command>' to run the script."
;; TODO: rebind compile to C-c and auto fill sh with filename
;; TODO: rebind recompile to ??? to use last compile command
;; https://masteringemacs.org/article/compiling-running-scripts-emacs
;; TODO: for shell-script buffers:
;; ;;; Shut up compile saves
;; (setq compilation-ask-about-save nil)
;; ;;; Don't save *anything*
;; (setq compilation-save-buffers-predicate '(lambda () nil))
(interactive)
(delete-other-windows)
(split-window-horizontally (truncate (* 0.6 (window-body-width))))
(other-window 1)
(switch-to-buffer "*compilation*")
(other-window -1)
)
(defun my-view-org-pdf ()
"Two windows side-by-side.
On the right side a DocView buffer displaying the pdf."
(interactive)
(delete-other-windows)
(let ((bufnam (buffer-name))
(buffilnam buffer-file-name))
(split-window-horizontally)
(other-window 1)
;;(switch-to-buffer (concat (file-name-sans-extension bufnam) ".pdf"))
(find-file (concat (file-name-sans-extension buffilnam) ".pdf"))
(doc-view-fit-height-to-window)
(doc-view-fit-window-to-page)
(other-window -1)
))
(defun my-view-gnuplot ()
"Three windows.
On the right side a *Shell* buffer with optionally
`virtual-auto-fill-mode' active and an Image mode buffer."
(interactive)
(save-excursion
(let (output-file-name) ;; get figure output name
(goto-char (point-min))
(when (re-search-forward "set output .*" nil t)
;; TODO: search text in between set output '...' then I do not
;; need to replace / remove part of the match string.
(setq output-file-name (match-string 0))
(setq output-file-name (string-replace "set output " "" output-file-name))
(setq output-file-name (substring output-file-name 1 -1)))
;;(message "%s" output-file-name)
(delete-other-windows)
(split-window-horizontally (truncate (* 0.6 (window-body-width))))
(other-window 1)
(if output-file-name
;;(switch-to-buffer output-file-name)
(find-file output-file-name)
;;(switch-to-buffer "*scratch*")
(switch-to-buffer " *image*"))
;;(when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
(split-window-vertically) ;; both are shell buffers now.
(switch-to-buffer "*shell*")
(shell)
;;(when (fboundp 'virtual-auto-fill-mode) (virtual-auto-fill-mode))
(other-window -1))))
(provide 'my)
;;; my.el ends here