From f88da07d45a58b770f2a5c0501fc3cc10e943620 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 31 Jan 2020 18:11:24 +0100 Subject: [PATCH] fixes and other old changes --- bba.org | 711 +++++++++++++++++++++++++++++++++--- custom.el | 45 ++- elpa/gnupg/pubring.gpg | Bin 999 -> 2349 bytes elpa/gnupg/trustdb.gpg | Bin 1200 -> 1200 bytes init.el | 1 + snippets/org-mode/pagerduty | 2 +- snippets/sql-mode/lstables | 8 +- 7 files changed, 713 insertions(+), 54 deletions(-) diff --git a/bba.org b/bba.org index a239ceaf..d12da679 100644 --- a/bba.org +++ b/bba.org @@ -157,8 +157,9 @@ from bash. (let ((path (shell-command-to-string ". ~/.bashrc >/dev/null; echo -n $https_proxy"))) (setenv "https_proxy" path) ) - ) - ) + (let ((path (shell-command-to-string ". ~/.bashrc >/dev/null; echo -n $INFOPATH"))) + (setenv "INFOPATH" path)) + (push "/opt/local/share/info" Info-directory-list))) #+END_SRC * move files to trash on osx @@ -300,7 +301,6 @@ Keep track of your important stuff! (require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) - (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")) ) (progn @@ -799,6 +799,7 @@ Adjust indentation at work. (add-hook 'yaml-mode-hook (lambda() (auto-fill-mode -1) + (stripes-mode 1) (setq bba-keep-whitespaces 1))) #+END_SRC @@ -974,6 +975,43 @@ this is how your firefox bookmark must look like: #+END_SRC +** org-man +[2018-08-28 Tue 16:57] + +#+BEGIN_SRC emacs-lisp :tangle yes + (org-add-link-type "man" 'org-man-open) + (add-hook 'org-store-link-functions 'org-man-store-link) + + (defcustom org-man-command 'man + "The Emacs command to be used to display a man page." + :group 'org-link + :type '(choice (const man) (const woman))) + + (defun org-man-open (path) + "Visit the manpage on PATH. + PATH should be a topic that can be thrown at the man command." + (funcall org-man-command path)) + + (defun org-man-store-link () + "Store a link to a manpage." + (when (memq major-mode '(Man-mode woman-mode)) + ;; This is a man page, we do make this link + (let* ((page (org-man-get-page-name)) + (link (concat "man:" page)) + (description (format "Manpage for %s" page))) + (org-store-link-props + :type "man" + :link link + :description description)))) + + (defun org-man-get-page-name () + "Extract the page name from the buffer name." + ;; This works for both `Man-mode' and `woman-mode'. + (if (string-match " \\(\\S-+\\)\\*" (buffer-name)) + (match-string 1 (buffer-name)) + (error "Cannot create link to this man page"))) + +#+END_SRC ** [[https://github.com/stig/ob-applescript.el][ob-applescript]] [2016-09-27 Tue 09:34] @@ -1163,6 +1201,9 @@ Get reveal.js as well: :html-link-home "http://www.bundesbrandschatzamt.de/~baron/" :html-link-use-abs-url t :with-toc nil + :with-author nil + :with-email nil + :with-creator nil :exclude ".*" :include ("index.org")))) @@ -1208,7 +1249,38 @@ Get reveal.js as well: (define-key org-mode-map "\M-\S-w" 'bba-ox-clip-formatted-copy) #+END_SRC +** comint-write-buffer +[2018-01-09 Tue 14:10] +#+BEGIN_SRC emacs-lisp :tangle yes + (defun comint-write-output-buffer (buffername &optional append) + "Write output from interpreter since last input to BUFFER. + Any prompt at the end of the output is not written. + + If the optional argument APPEND (the prefix argument when interactive) + is non-nil, the output is appended to the buffer instead. + If it is nil existing buffer gets killed upon request." + (interactive + (list (read-buffer + (if current-prefix-arg + "Append output to buffer: " + "Write output to buffer: ")) + current-prefix-arg + )) + (if append + (get-buffer-create buffername) + (progn + (if (get-buffer buffername) + (kill-buffer-ask (get-buffer buffername))) + (get-buffer-create buffername) + ) + ) + (save-excursion + (goto-char (process-mark (get-buffer-process (current-buffer)))) + (forward-line 0) + (append-to-buffer buffername comint-last-input-end (point)))) + (define-key comint-mode-map (kbd "C-c s-s") 'comint-write-output-buffer) +#+END_SRC ** bba-create-ticket-tmp-dir [2017-07-28 Fri 13:07] @@ -1237,6 +1309,19 @@ Get reveal.js as well: (shell-command "osascript -e \'tell app \"Keyboard Maestro Engine\" to do script \"screen-start-cd-to-clipboard\"'") ) #+END_SRC +** bba-remove-comments-and-empty-lines +[2018-03-06 Tue 13:58] + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun bba-remove-comments-and-empty-lines() + "Remove all lines containing comments or nothing at all." + (interactive) + (goto-char (point-min)) + (let (kill-ring) + (comment-kill (count-lines (point-min)(point-max)))) + (goto-char (point-min)) + (flush-lines "^$")) +#+END_SRC ** search notes [2018-02-09 Fri 10:57] @@ -1382,8 +1467,10 @@ This is helpful in training sessions. (setq -p1 (region-beginning) -p2 (region-end)) (setq mark-active nil) (re-search-backward "\#\\+BEGIN_SRC") - (forward-line -1) - (if (not (looking-at "\#"))(forward-line)) + (forward-line -1) + (if (looking-at "\#\\+RESULTS:")(re-search-backward "\#\\+BEGIN_SRC")) + (forward-line -1) + (if (not (looking-at "\#"))(forward-line)) (set-mark-command nil) (forward-line) (beginning-of-line) @@ -1406,8 +1493,10 @@ This is helpful in training sessions. (progn (push-mark) (re-search-backward "\#\\+BEGIN_SRC") - (forward-line -1) - (if (not (looking-at "\#"))(forward-line)) + (forward-line -1) + (if (looking-at "\#\\+RESULTS:")(re-search-backward "\#\\+BEGIN_SRC")) + (forward-line -1) + (if (not (looking-at "\#"))(forward-line)) (set-mark-command nil) (re-search-forward "\#\\+END_SRC") (forward-line) @@ -1421,28 +1510,246 @@ This is helpful in training sessions. )) ) - (defun bba-copy-org-src-block() - "copy last org src block. Can be around point, too." - (interactive) + (defun bba-copy-org-src-block(arg) + "copy org src block. Can be around point, too. If POSITION is negative look backwards for x occurance, if positive search forwards." + (interactive "p") (push-mark) (goto-char (point-at-bol)) - (if (not (looking-at "\#\\+BEGIN_SRC"))(re-search-backward "\#\\+BEGIN_SRC")) - (forward-line -1) - (if (not (looking-at "\#"))(forward-line)) - (set-mark-command nil) - (re-search-forward "\#\\+END_SRC") - (forward-line) - (goto-char (point-at-bol)) - (kill-ring-save 1 1 1) - (set-mark-command '1) - (set-mark-command '1) + (if (not current-prefix-arg) + (progn + (message "foo %s" arg) + (if (not (looking-at "\#\\+BEGIN_SRC"))(re-search-backward "\#\\+BEGIN_SRC")) + (forward-line -1) + (if (looking-at "\#\\+RESULTS:")(re-search-backward "\#\\+BEGIN_SRC")) + (forward-line -1) + (if (not (looking-at "\#"))(forward-line)) + (set-mark-command nil) + (re-search-forward "\#\\+END_SRC") + (forward-line) + (goto-char (point-at-bol)) + (kill-ring-save 1 1 1) + (set-mark-command '1) + (set-mark-command '1)) + (progn + (re-search-forward "\#\\+BEGIN_SRC" nil nil arg) + (forward-line -1) + (if (not (looking-at "\#"))(forward-line)) + (set-mark-command nil) + (re-search-forward "\#\\+END_SRC") + (forward-line) + (goto-char (point-at-bol)) + (kill-ring-save 1 1 1) + (set-mark-command '1) + (set-mark-command '1) + (insert (pop kill-ring)) + (re-search-backward "\#\\+BEGIN_SRC") + (forward-line))) ) + + ;; (defun bba-copy-org-src-block() + ;; "copy last org src block. Can be around point, too." + ;; (interactive) + ;; (push-mark) + ;; (goto-char (point-at-bol)) + ;; (if (not (looking-at "\#\\+BEGIN_SRC"))(re-search-backward "\#\\+BEGIN_SRC")) + ;; (forward-line -1) + ;; (if (not (looking-at "\#"))(forward-line)) + ;; (set-mark-command nil) + ;; (re-search-forward "\#\\+END_SRC") + ;; (forward-line) + ;; (goto-char (point-at-bol)) + ;; (kill-ring-save 1 1 1) + ;; (set-mark-command '1) + ;; (set-mark-command '1) + ;; ) + (define-key org-mode-map "\C-c\S-w" 'bba-copy-and-yank-org-src-block) (define-key org-mode-map (kbd "C-c s-w") 'bba-copy-org-src-block) #+END_SRC +** org-babel-async +[2016-12-27 Tue 15:45] + +Thanks to [[http://kitchingroup.cheme.cmu.edu/blog/2015/11/20/Asynchronously-running-python-blocks-in-org-mode/#disqus_thread][Asynchronously running pyton bocks in org-mode]] + +Still some work to do on the shell counterpart. +=:dir= is not recongnised. + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun org-babel-async-execute:shell () + "Execute the sh src-block at point asynchronously. + :var headers are supported. + :results output is all that is supported for output. + + A new window will pop up showing you the output as it appears, + and the output in that window will be put in the RESULTS section + of the code block." + (interactive) + (require 'org-id) + (require 'ob-core) + (let* ((current-file (buffer-file-name)) + (uuid (org-id-uuid)) + (code (org-element-property :value (org-element-context))) + (temporary-file-directory "/tmp/") + (tempfile (make-temp-file "sh-")) + (pbuffer (format "*%s*" uuid)) + (varcmds (org-babel-variable-assignments:shell + (nth 2 (org-babel-get-src-block-info)))) + process) + + ;; get rid of old results, and put a place-holder for the new results to + ;; come. + (org-babel-remove-result) + + (save-excursion + (re-search-forward "#\\+END_SRC") + (insert (format + "\n\n#+RESULTS: %s\n: %s" + (or (org-element-property :name (org-element-context)) + "") + uuid))) + + ;; open the results buffer to see the results in. + ;; (switch-to-buffer-other-window pbuffer) + + ;; Create temp file containing the code. + (with-temp-file tempfile + ;; if there are :var headers insert them. + (dolist (cmd varcmds) + (insert cmd) + (insert "\n")) + (insert code)) + + ;; run the code + (setq process (start-process + uuid + pbuffer + "bash" + tempfile)) + + ;; when the process is done, run this code to put the results in the + ;; org-mode buffer. + (set-process-sentinel + process + `(lambda (process event) + (save-window-excursion + (save-excursion + (save-restriction + (with-current-buffer (find-file-noselect ,current-file) + (goto-char (point-min)) + (re-search-forward ,uuid) + (beginning-of-line) + (kill-line) + (insert "#+begin_example") + (newline) + (insert + (mapconcat + (lambda (x) + (format "%s" x)) + (butlast (split-string + (with-current-buffer + ,pbuffer + (buffer-string)) + "\n")) + "\n")) + (newline) + (insert "#+end_example") + + )))) + + ;; delete the results buffer then delete the tempfile. + ;; finally, delete the process. + (when (get-buffer ,pbuffer) + (kill-buffer ,pbuffer) + (delete-window)) + (delete-file ,tempfile) + (delete-process process)))) + ) + (define-key org-mode-map (kbd "C-c C-S-c") 'org-babel-async-execute:shell) +#+END_SRC + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun org-babel-async-execute:python () + "Execute the python src-block at point asynchronously. + :var headers are supported. + :results output is all that is supported for output. + + A new window will pop up showing you the output as it appears, + and the output in that window will be put in the RESULTS section + of the code block." + (interactive) + (let* ((current-file (buffer-file-name)) + (uuid (org-id-uuid)) + (code (org-element-property :value (org-element-context))) + (temporary-file-directory ".") + (tempfile (make-temp-file "py-")) + (pbuffer (format "*%s*" uuid)) + (varcmds (org-babel-variable-assignments:python + (nth 2 (org-babel-get-src-block-info)))) + process) + + ;; get rid of old results, and put a place-holder for the new results to + ;; come. + (org-babel-remove-result) + + (save-excursion + (re-search-forward "#\\+END_SRC") + (insert (format + "\n\n#+RESULTS: %s\n: %s" + (or (org-element-property :name (org-element-context)) + "") + uuid))) + + ;; open the results buffer to see the results in. + (switch-to-buffer-other-window pbuffer) + + ;; Create temp file containing the code. + (with-temp-file tempfile + ;; if there are :var headers insert them. + (dolist (cmd varcmds) + (insert cmd) + (insert "\n")) + (insert code)) + + ;; run the code + (setq process (start-process + uuid + pbuffer + "python" + tempfile)) + + ;; when the process is done, run this code to put the results in the + ;; org-mode buffer. + (set-process-sentinel + process + `(lambda (process event) + (save-window-excursion + (save-excursion + (save-restriction + (with-current-buffer (find-file-noselect ,current-file) + (goto-char (point-min)) + (re-search-forward ,uuid) + (beginning-of-line) + (kill-line) + (insert + (mapconcat + (lambda (x) + (format ": %s" x)) + (butlast (split-string + (with-current-buffer + ,pbuffer + (buffer-string)) + "\n")) + "\n")))))) + ;; delete the results buffer then delete the tempfile. + ;; finally, delete the process. + (when (get-buffer ,pbuffer) + (kill-buffer ,pbuffer) + (delete-window)) + (delete-file ,tempfile) + (delete-process process))))) #+END_SRC ** tmux capture-pane @@ -1921,6 +2228,39 @@ taken from http://doc.norang.ca/org-mode.org #+END_SRC +#+BEGIN_SRC emacs-lisp :tangle yes + (setq org-duration-format '((special . h:mm))) +#+END_SRC + +** clocktable +[2016-04-15 Fri 17:05] + +Assuming that I understood your problem correctly, I hacked together a +quick solution. First, you should ensure that you create only one +outline entry per day, if you are checking in and out multiple +times. Define the following function that'll compute the overtime for +a given day. + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun compute-overtime (duration-string) + "Computes overtime duration string for the given time DURATION-STRING." + (let (minutes-in-a-workday + work-minutes + overtime-minutes) + (defconst minutes-in-a-workday 480) + (setq work-minutes (org-duration-to-minutes duration-string) + overtime-minutes (- work-minutes minutes-in-a-workday)) + (if (< overtime-minutes 0) (setq overtime-minutes 0)) + (org-minutes-to-hh:mm-string overtime-minutes))) +#+END_SRC + +Then, use this in a clock table formula in the file whatnot. + +#+BEGIN_SRC org + ,#+BEGIN: clocktable :maxlevel 1 :emphasize nil :scope file :formula "$3='(compute-overtime $2)::@2$3=string(\"Overtime\")" + ,#+END: clocktable +#+END_SRC + ** youtube links Thanks to [[http://endlessparentheses.com/embedding-youtube-videos-with-org-mode-links.html][endlessparentheses]]: Youtube makes it pretty simple @@ -1960,6 +2300,39 @@ that Youtube specifies. The advantage (over simply writing out the iframe) is that this link can be clicked in org-mode, and can be exported to other formats as well. +** [[http://kitchingroup.cheme.cmu.edu/blog/2016/03/21/Displaying-image-overlays-on-image-filenames-in-Emacs/][Displaying image overlays on image filenames in Emacs]] +[2016-11-09 Wed 12:57] + +Thanks to John Kitchin we can display images in Emacs. + +#+BEGIN_SRC emacs-lisp :tangle yes + (defvar image-tooltip-re (concat "\\(?3:'\\|\"\\)\\(?1:.*\\." + (regexp-opt '("png" "PNG" "JPG" "jpeg" + "jpg" "JPEG" "eps" "EPS")) + "\\)\\(?:\\3\\)") + "Regexp to match image filenames in quotes") + + (defun image-tooltip (window object position) + (save-excursion + (goto-char position) + (let (beg end imgfile img s) + (while (not (looking-at image-tooltip-re)) + (forward-char -1)) + (setq imgfile (match-string-no-properties 1)) + (when (file-exists-p imgfile) + (setq img (create-image (expand-file-name imgfile) + 'imagemagick nil :width 200)) + (propertize "Look in the minibuffer" + 'display img))))) + + (font-lock-add-keywords + nil + `((,image-tooltip-re + 0 '(face font-lock-keyword-face + help-echo image-tooltip)))) + + (font-lock-ensure) +#+END_SRC ** org-mime-org-buffer-htmlize @@ -2071,6 +2444,13 @@ file. ) #+END_SRC +** [[https://github.com/dfeich/org-listcruncher][org-listcruncher]] +[2018-05-24 Thu 09:08] + +#+BEGIN_SRC emacs-lisp :tangle yes + (load-file (expand-file-name "~/.emacs.d/lisp/org-listcruncher.el")) + +#+END_SRC ** additional org settings [2016-11-03 Thu 09:36] Thanks to [[https://github.com/dakrone/eos/blob/master/eos-org.org][eos-org]]. @@ -2554,6 +2934,19 @@ list who can decrypt a file: #+END_SRC +* Go +[2019-09-12 Thu 16:00] + +#+begin_src emacs-lisp :tangle yes + (add-hook 'go-mode-hook + (lambda () + (add-hook 'before-save-hook 'gofmt-before-save) + (setq-default) + (setq tab-width 4) + (setq standard-indent 4) + (setq indent-tabs-mode nil))) +#+end_src + * auto-completion #+BEGIN_SRC emacs-lisp :tangle yes @@ -2565,6 +2958,9 @@ list who can decrypt a file: (add-to-list 'ac-modes 'cfengine3-mode) (add-to-list 'ac-modes 'dns-mode) (add-to-list 'ac-sources 'ac-source-yasnippet) + (add-to-list 'ac-sources 'org-mode) + + (setq ac-trigger-key "S-SPC") #+END_SRC @@ -2642,7 +3038,13 @@ Combine abbrev with Ispell: (global-font-lock-mode 1) #+END_SRC +* lsp +[2020-01-16 Thu 11:26] +#+begin_src emacs-lisp :tangle no + (lsp-define-stdio-client lsp-sql "sql" + (lsp-make-traverser #'(lambda (dir) (directory-files dir nil "sss.sql"))) '("~/.vscode/extensions/ms-mssql.mssql-1.4.0/sqltoolsservice/1.4.0/Ubuntu16/MicrosoftSqlToolsServiceLayer")) +#+end_src * sql [2016-11-27 Sun 17:56] @@ -2677,7 +3079,7 @@ your =~/.emacs_secrets.el.gpg= might look like: (sql-server "host42.foo.com") (sql-user "dbadmin") (sql-password "foo") - (sql-database "smaatoprd")) + (sql-database "bbaprd")) (bbatst (sql-product 'vertica) (sql-server "host42.foo.com") (sql-user "dbadmin") @@ -2688,6 +3090,44 @@ your =~/.emacs_secrets.el.gpg= might look like: (provide 'my-password) #+END_SRC + +#+begin_src emacs-lisp :tangle yes + (defun my-sql-save-history-hook () + (let ((lval 'sql-input-ring-file-name) + (rval 'sql-product)) + (if (symbol-value rval) + (let ((filename + (concat (if (equal "work" (getenv "SYSENV")) + "~/workorg/sql/" + "~/org/sql/") + (symbol-name (symbol-value rval)) + "-history.sql"))) + (set (make-local-variable lval) filename)) + (error + (format "SQL history will not be saved because %s is nil" + (symbol-name rval)))))) + + (add-hook 'sql-interactive-mode-hook 'my-sql-save-history-hook) +#+end_src + +incorporate helm-comint-mode-list + +#+begin_src emacs-lisp :tangle yes + (require 'sql) + (require 'helm-comint) + (defun helm-comint-sqli-input-ring () + "Preconfigured `helm' that provide completion of `comint' history." + (interactive) ;; seq-contains helm-comint-mode-list major-mode + (when (or (member major-mode helm-comint-mode-list) + (derived-mode-p 'comint-mode)) + (helm :sources 'helm-source-comint-input-ring + :input (buffer-substring-no-properties (comint-line-beginning-position) + (point-at-eol)) + :buffer "*helm comint history*"))) + + (define-key sql-interactive-mode-map (kbd "M-p") 'helm-comint-sqli-input-ring) + +#+end_src * [[https://github.com/steckerhalter/sqlformat.el][sqlformat]] [2016-08-19 Fri 16:20] @@ -2751,11 +3191,7 @@ like these: (lambda() (unless (boundp 'bba-keep-whitespaces) (save-excursion - (delete-trailing-whitespace))) - ) - ) - ) - )) + (delete-trailing-whitespace)))))))) (eval-after-load "cperl-mode" @@ -3318,6 +3754,58 @@ Thanks to [[http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line (define-key global-map (kbd "M-w") 'xah-copy-line-or-region) #+END_SRC +* bba copy line or region to iterm +[2018-10-10 Wed 12:11] + +Based on xah-copy-line-or-region I wrote a version which copies just +the current line or region ( no append) and insert it via Keyboard +Maestro in my iterm. Quite useful to execute SQL commands in a remote +gnu screen session. I don't append a newline thus I can still verify +the clipboard content before executing it. + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun bba-copy-line-or-region-to-iterm () + "Copy current line, or text selection and insert it in iterm via Keyboard Maestro. + When `universal-argument' is called first, copy whole buffer (respects `narrow-to-region')." + + (interactive) + (let (-p1 -p2) + (if current-prefix-arg + (setq -p1 (point-min) -p2 (point-max)) + (if (use-region-p) + (setq -p1 (region-beginning) -p2 (region-end)) + (setq -p1 (line-beginning-position) -p2 (line-end-position)))) + (progn + (kill-ring-save -p1 -p2) + (if current-prefix-arg + (message "Buffer text copied") + (message "Text copied"))) + (if (not (use-region-p)) + (progn + (end-of-line) + (forward-char)) + )) + (shell-command "osascript -e \'tell app \"Keyboard Maestro Engine\" to do script \"iterm-insert-clipboard\"'" ) + ) + + (define-key global-map (kbd "s-w") 'bba-copy-line-or-region-to-iterm) +#+END_SRC + +* bba lookup dictionary +[2019-05-27 Mon 15:15] +coffee mug +#+BEGIN_SRC emacs-lisp :tangle yes + (defun bba-dict () + "Lookup thing at point in OS X Dictionary." + (interactive) + (if (use-region-p) + (shell-command (concat "open dict://\"" (buffer-substring (region-beginning)(region-end)) "\"")) + (shell-command (concat "open dict://" (thing-at-point 'symbol))) + ) + ) + (define-key global-map (kbd "s-l") 'bba-dict) + +#+END_SRC * [[http://ergoemacs.org/emacs/emacs_navigating_keys_for_brackets.html][Xah Lee Move cursor to Bracket]] [2017-03-27 Mon 22:41] @@ -3462,7 +3950,7 @@ Some links you might check out: (define-key global-map "\C-x\C-b" 'helm-buffers-list) (define-key global-map "\C-x\C-k\C-h" 'helm-execute-kmacro) (define-key global-map (kbd "C-x r b") 'helm-bookmarks) - (define-key global-map (kbd "C-x C-S-f") 'helm-find-files) + (define-key global-map (kbd "C-x C-f") 'helm-find-files) (define-key global-map "\C-cy" 'helm-yas-complete) (define-key org-mode-map "\C-ci" 'helm-org-in-buffer-headings) (setq helm-yas-display-key-on-candidate t) @@ -3540,7 +4028,7 @@ combine key strokes to access commands even faster. (key-chord-define-global "xb" 'helm-mini) (key-chord-define-global "xf" 'ido-find-file) (key-chord-define-global "xx" 'helm-M-x) - (key-chord-define org-mode-map "TT" 'org-set-tags) + (key-chord-define org-mode-map "TT" 'org-set-tags-command) @@ -3601,6 +4089,7 @@ character before any spaces." #+BEGIN_SRC emacs-lisp :tangle yes (define-key global-map (kbd "M-@") 'cycle-spacing) (define-key global-map (kbd "M-SPC") 'cycle-spacing) + (define-key global-map (kbd "S-SPC") 'dabbrev-expand) (define-key global-map (kbd "s-r") 'repeat) (define-key global-map "\C-x\S-f" 'find-file-at-point) @@ -3611,6 +4100,8 @@ character before any spaces." (define-key global-map (kbd "C-c M-s") 'string-edit-at-point) + (define-key global-map (kbd "s-i") 'indent-region) + (define-key global-map "\C-cp" 'org-mark-ring-push) (define-key global-map "\C-cn" 'org-mark-ring-goto) @@ -3815,6 +4306,31 @@ Adjust mouse speed: (setq mouse-wheel-progressive-speed nil) #+END_SRC +* string-inflection +[2019-02-08 Fri 12:14] + +#+BEGIN_SRC emacs-lisp :tangle yes + (require 'string-inflection) + (global-set-key (kbd "M-S-TAB") 'bba-string-inflection-cycle) + + (defun bba-string-inflection-cycle-auto () + "switching by major-mode" + (interactive) + (cond + ;; for emacs-lisp-mode + ((eq major-mode 'emacs-lisp-mode) + (string-inflection-all-cycle)) + ;; for java + ((eq major-mode 'java-mode) + (string-inflection-java-style-cycle)) + ;; for python + ((eq major-mode 'python-mode) + (string-inflection-python-style-cycle)) + (t + ;; default + (string-inflection-ruby-style-cycle)))) + +#+END_SRC * By indentation Borrowed from [[https://github.com/Wilfred/.emacs.d][github]]: @@ -4165,7 +4681,24 @@ update copyrights (copyright-update)))) #+END_SRC -* other stuff +#+BEGIN_SRC emacs-lisp :tangle yes + (add-to-list 'Info-additional-directory-list "~/.emacs.d/info") +#+END_SRC + +#+BEGIN_SRC emacs-lisp :tangle yes + (require 'info-look) + (info-lookup-add-help + :mode 'python-mode + :regexp "[[:alnum:]_]+" + :doc-spec + '(("(python)Index" nil ""))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp :tangle yes + (setq mouse-yank-at-point t) +#+END_SRC + +* TODO other stuff #+BEGIN_SRC emacs-lisp :tangle yes @@ -4292,17 +4825,17 @@ whole team. No matter what editor gets used. (if (display-graphic-p) (progn - (custom-set-faces - '(org-block-begin-line ((t (:background "#07538a" :foreground "#84cbef"))) t) - '(org-block-end-line ((t (:inherit org-block-begin-line))) t) - '(org-block ((t (:inherit shadow :background "#29759c" :foreground "#84cbef" :distant-forground "#131313")))) - ;; '(show-paren-match ((t (:distant-foreground "#29759c":background "#84cbef" )))) - ;;'(show-paren-match ((t (:inverse-video t)))) + (custom-set-faces + '(org-block-begin-line ((t (:background "#07538a" :foreground "#84cbef"))) t) + '(org-block-end-line ((t (:inherit org-block-begin-line))) t) + '(org-block ((t (:inherit shadow :background "#29759c" :foreground "#84cbef" :distant-forground "#131313")))) + ;; '(show-paren-match ((t (:distant-foreground "#29759c":background "#84cbef" )))) + ;;'(show-paren-match ((t (:inverse-video t)))) '(show-paren-match ((t (:underline (:color "#07e30d" :style line))))) '(show-paren-mismatch ((t (:underline (:color "red" :style wave))))) - ;; '(show-paren-match ((t (:unterline (:color "#b8bb26" :style wave))))) - ) - (let* ((variable-tuple (cond ((x-list-fonts "Arial") '(:font "Arial")) + ;; '(show-paren-match ((t (:unterline (:color "#b8bb26" :style wave))))) + ) + (let* ((variable-tuple (cond ((x-list-fonts "Arial") '(:font "Arial")) ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro")) ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande")) ((x-list-fonts "Verdana") '(:font "Verdana")) @@ -4321,12 +4854,19 @@ whole team. No matter what editor gets used. `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.4)))) `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.6)))) `(org-document-title ((t (,@headline ,@variable-tuple :height 1.5 :underline nil))))) - (custom-set-variables - '(ansi-color-names-vector - ["black" "red3" "green3" "yellow3" "LightSkyBlue1" "magenta3" "cyan3" "gray90"])) - ))) + (custom-set-variables + '(ansi-color-names-vector + ["black" "red3" "green3" "yellow3" "LightSkyBlue1" "magenta3" "cyan3" "gray90"])) + ))) #+END_SRC +* transparent window +[2018-03-07 Wed 10:42] + +#+BEGIN_SRC emacs-lisp :tangle yes + (set-frame-parameter (selected-frame) 'alpha '(100 . 96 )) + (add-to-list 'default-frame-alist '(alpha . (100 . 96))) +#+END_SRC * load custom file [2014-10-02 Thu 00:37] @@ -4396,18 +4936,27 @@ all in your history. (if (equal "work" (getenv "SYSENV")) (if (file-exists-p "~/workorg") (setq savehist-file "~/workorg/emacshistory") - ) + ) (if (file-exists-p "~/org") - (setq savehist-file "~/org/emacshistory") + (setq savehist-file "~/org/emacshistory") ) (if (file-exists-p savehist-file) - (load-file savehist-file) - ) + (load-file savehist-file) + ) ) (savehist-mode 1) #+END_SRC +* save place +[2019-11-06 Wed 15:53] + +#+begin_src emacs-lisp :tangle yes + (setq save-place-file "~/.emacs-places") + (save-place-mode 1) + ;; (setq save-place-forget-unreadable-files nil) +#+end_src + * start ssh in screen session [2016-02-11 Thu 12:42] @@ -4459,6 +5008,8 @@ Check a AWS Cloudformation template with [[https://github.com/stelligent/cfn_nag (shell-command (concat "cfn_nag_scan --input-path " buffer-file-name))) (require 'json-mode) (define-key json-mode-map (kbd "C-c C-n") 'bba-aws-cfn-nag-scan) + (require 'yaml-mode) + (define-key yaml-mode-map (kbd "C-c C-n") 'bba-aws-cfn-nag-scan) #+END_SRC Check a AWS Cloudformation template with [[https://github.com/awslabs/cfn-python-lint][cfn-lint]]: @@ -4467,8 +5018,11 @@ Check a AWS Cloudformation template with [[https://github.com/awslabs/cfn-python (defun bba-aws-cfn-lint() "Check buffer with cfn_lint." (interactive) - (shell-command (concat "cfn-lint " buffer-file-name))) + (if (file-exists-p "~/.cfn-lint-override.json") + (shell-command (concat "cfn-lint --override-spec ~/.cfn-lint-override.json " buffer-file-name)) + (shell-command (concat "cfn-lint " buffer-file-name)))) (define-key json-mode-map (kbd "C-c C-l") 'bba-aws-cfn-lint) + (define-key yaml-mode-map (kbd "C-c C-l") 'bba-aws-cfn-lint) #+END_SRC @@ -4516,6 +5070,69 @@ Amazon instance ID at point. 'instanceid-bounds-of-instanceid-at-point) #+END_SRC +* bba-emacs-keyboard-map +[2016-03-15 Tue 09:49] + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun bba-emacs-keyboard-map () + "create a keyboard map in a buffer." + (interactive) + (switch-to-buffer "*keyboard-map*") + (erase-buffer) + (org-mode) + (insert "|1|2|3|4|5|6|7|8|9|0|-|=|back|") + (newline) + (insert "|q|w|e|r|t|y|u|i|o|p|[|]|") + ;; (org-table-align) + (newline) + (insert "|") + (insert "M-q " )(insert (format "%s" (lookup-key global-map (kbd "M-q"))) "|") + (insert "M-w " )(insert (format "%s" (lookup-key global-map (kbd "M-w"))) "|") + (insert "M-e " )(insert (format "%s" (lookup-key global-map (kbd "M-e"))) "|") + (insert "M-r " )(insert (format "%s" (lookup-key global-map (kbd "M-r"))) "|") + (insert "M-t " )(insert (format "%s" (lookup-key global-map (kbd "M-t"))) "|") + (insert "M-y " )(insert (format "%s" (lookup-key global-map (kbd "M-y"))) "|") + (insert "M-u " )(insert (format "%s" (lookup-key global-map (kbd "M-u"))) "|") + (insert "M-i " )(insert (format "%s" (lookup-key global-map (kbd "M-i"))) "|") + (insert "M-o " )(insert (format "%s" (lookup-key global-map (kbd "M-o"))) "|") + (insert "M-p " )(insert (format "%s" (lookup-key global-map (kbd "M-p"))) "|") + (insert "M-[ " )(insert (format "%s" (lookup-key global-map (kbd "M-["))) "|") + (insert "M-] " )(insert (format "%s" (lookup-key global-map (kbd "M-]"))) "|") + (newline) + (insert "|a|s|d|f|g|h|j|k|l|;|'|") + (newline) + (insert "|") + (insert "M-a " )(insert (format "%s" (lookup-key global-map (kbd "M-a"))) "|") + (insert "M-s " )(insert "key-chord key" "|") + (insert "M-d " )(insert (format "%s" (lookup-key global-map (kbd "M-d"))) "|") + (insert "M-f " )(insert (format "%s" (lookup-key global-map (kbd "M-f"))) "|") + (insert "M-g " )(insert "key-chord key" "|") + (insert "M-h " )(insert (format "%s" (lookup-key global-map (kbd "M-h"))) "|") + (insert "M-j " )(insert (format "%s" (lookup-key global-map (kbd "M-j"))) "|") + (insert "M-k " )(insert (format "%s" (lookup-key global-map (kbd "M-k"))) "|") + (insert "M-l " )(insert (format "%s" (lookup-key global-map (kbd "M-l"))) "|") + (insert "M-; " )(insert (format "%s" (lookup-key global-map (kbd "M-;"))) "|") + (insert "M-\' " )(insert (format "%s" (lookup-key global-map (kbd "M-'"))) "|") + (newline) + (insert "|z|x|c|v|b|n|m|,|.|/|") + (newline) + (insert "|") + (insert "M-z " )(insert (format "%s" (lookup-key global-map (kbd "M-z"))) "|") + (insert "M-x " )(insert (format "%s" (lookup-key global-map (kbd "M-x"))) "|") + (insert "M-c " )(insert (format "%s" (lookup-key global-map (kbd "M-c"))) "|") + (insert "M-v " )(insert (format "%s" (lookup-key global-map (kbd "M-v"))) "|") + (insert "M-b " )(insert (format "%s" (lookup-key global-map (kbd "M-b"))) "|") + (insert "M-n " )(insert (format "%s" (lookup-key global-map (kbd "M-n"))) "|") + (insert "M-m " )(insert (format "%s" (lookup-key global-map (kbd "M-m"))) "|") + (insert "M-, " )(insert (format "%s" (lookup-key global-map (kbd "M-,"))) "|") + (insert "M-. " )(insert (format "%s" (lookup-key global-map (kbd "M-."))) "|") + (insert "M-/ " )(insert (format "%s" (lookup-key global-map (kbd "M-/"))) "|") + + (newline) + ) + +#+END_SRC + * post [2015-10-02 Fri 13:26] diff --git a/custom.el b/custom.el index b13c6a40..3fb1fe33 100644 --- a/custom.el +++ b/custom.el @@ -3,24 +3,65 @@ ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. + '(ansi-color-names-vector + ["black" "red3" "green3" "yellow3" "LightSkyBlue1" "magenta3" "cyan3" "gray90"]) + '(aws-snippets-ec2-list-instances-query + (quote + ("Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0],Tags[?Key==`Schedule`].Value[] | [0],InstanceId, State.Name, PublicDnsName, InstanceType,Placement.AvailabilityZone,LaunchTime]" "Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0],Tags[?Key==`Schedule`].Value[] | [0],InstanceId, State.Name, PublicDnsName, InstanceType,Placement.AvailabilityZone,LaunchTime, IamInstanceProfile.Arn]" "Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0],Tags[?Key==`Schedule`].Value[] | [0],InstanceId, State.Name, PublicDnsName, InstanceType,Placement.AvailabilityZone,LaunchTime, KeyName]" "Reservations[].Instances[?IamInstanceProfile.Arn==null].[Tags[?Key==`Name`].Value[] | [0],Tags[?Key==`Type`].Value[] | [0],Tags[?Key==`Project`].Value[] | [0],InstanceId, State.Name, PublicDnsName, InstanceType,Placement.AvailabilityZone,LaunchTime, IamInstanceProfile.Arn]"))) + '(aws-snippets-profiles (quote ("test" "prod" "cn"))) + '(aws-snippets-regions + (quote + ("us-east-1" "eu-west-1" "ap-southeast-1" "cn-north-1"))) '(blink-cursor-mode t) '(custom-safe-themes (quote ("8db4b03b9ae654d4a57804286eb3e332725c84d7cdab38463cb6b97d5762ad26" default))) '(gnuserv-program (concat exec-directory "/gnuserv")) + '(grep-template "grep -i -nH -e ") + '(helm-comint-mode-list (quote (comint-mode slime-repl-mode sql-interactive-mode))) '(history-length 1000) + '(magit-commit-arguments (quote ("--signoff" "--gpg-sign=43BA01102D205F88"))) '(magit-commit-signoff t) '(magit-git-global-arguments (quote ("--no-pager"))) + '(magit-log-arguments (quote ("--graph" "--decorate" "-n256"))) + '(magit-log-margin (quote (t "%Y-%m-%d %H:%M " magit-log-margin-width t 18))) + '(magit-pull-arguments nil) '(magit-repo-dirs (quote ("~/git"))) + '(org-agenda-files + (quote + ("~/workorg/work.org" "~/org/notes.org" "~/org/emacs.org" "~/org/it.org" "~/org/refile.org" "~/org/workhours.org"))) + '(package-selected-packages + (quote + (yasnippet with-editor treepy transient simple-httpd request markdown-mode magit-popup hydra htmlize hl-todo helm git-commit f elfeed dash-functional dash clomacs clojure-mode async magit org lsp-mode git-link eglot helm-org biblio parsebib parseedn lv yaml-mode xah-lookup x-path-walker visual-regexp visual-ascii-mode vertica-snippets undo-tree twittering-mode tt-mode tldr terraform-mode tabulated-list sx string-inflection string-edit sqlup-mode sokoban smartparens sicp s3ed rhtml-mode restclient-helm rainbow-mode rainbow-delimiters puppet-mode paradox pacmacs package-lint ox-reveal ox-jira ox-clip org-tree-slide org-sticky-header org-ref org-plus-contrib org-mime org-jira org-chef org-ac ob-tmux ob-restclient ob-cfengine3 ob-async neotree mwe-log-commands mustache multiple-cursors mew magit-todos magit-gitflow langtool keyfreq json-mode impatient-mode highlight-symbol helm-swoop helm-safari helm-projectile helm-gtags helm-git helm-descbinds helm-c-yasnippet helm-aws guide-key graphql go-snippets go-mode gnuplot git-timemachine ghub ggtags fullscreen-mode fullframe flymake-yaml flymake-puppet flymake-perlcritic flymake-json flycheck fast-scroll expand-region ess epoch-view engine-mode elfeed-org ejc-sql editorconfig edit-indirect dired-narrow dired+ demo-it debian-changelog-mode csv-nav csv-mode command-log-mode color-identifiers-mode centered-cursor-mode bug-hunter aws-snippets avy ascii artbollocks-mode apples-mode ac-helm))) '(package-user-dir "~/.emacs.d/elpa") '(paradox-github-token t) '(safe-local-variable-values (quote ((bba-keep-whitespaces . 1)))) '(template-default-directories (quote ("~/.emacs.d/templates/"))) '(toolbar-visible-p nil) - '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Hg Mtn Arch)))) -(defcustom sql-mysql-program "/usr/local/mysql/bin/mysql" + '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Hg Arch)))) +(defcustom sql-mysql-program "~/bin/mysql" "*Command to start mysql by mysqlDB." :type 'file :group 'SQL) (setq minibuffer-max-depth nil) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(org-block ((t (:inherit shadow :background "#29759c" :foreground "#84cbef" :distant-forground "#131313")))) + '(org-block-begin-line ((t (:background "#07538a" :foreground "#84cbef")))) + '(org-block-end-line ((t (:inherit org-block-begin-line)))) + '(org-document-title ((t (:inherit default :foreground "#62a9cd" :font "Arial" :height 1.5 :underline nil)))) + '(org-level-1 ((t (:inherit default :foreground "#62a9cd" :font "Arial" :height 1.6)))) + '(org-level-2 ((t (:inherit default :foreground "#62a9cd" :font "Arial" :height 1.4)))) + '(org-level-3 ((t (:inherit default :foreground "#62a9cd" :font "Arial" :height 1.25)))) + '(org-level-4 ((t (:inherit default :foreground "#62a9cd" :font "Arial" :height 1.1)))) + '(org-level-5 ((t (:inherit default :foreground "#62a9cd" :font "Arial")))) + '(org-level-6 ((t (:inherit default :foreground "#62a9cd" :font "Arial")))) + '(org-level-7 ((t (:inherit default :foreground "#62a9cd" :font "Arial")))) + '(org-level-8 ((t (:inherit default :foreground "#62a9cd" :font "Arial")))) + '(show-paren-match ((t (:underline (:color "#07e30d" :style line))))) + '(show-paren-mismatch ((t (:underline (:color "red" :style wave))))) + '(stripes-face ((t :background "gray0")))) diff --git a/elpa/gnupg/pubring.gpg b/elpa/gnupg/pubring.gpg index e76e68522f36382fa5897866680fdb5afc73abdb..4d573d0ee2c5ffa9b1270385cafd71fb05b41a52 100644 GIT binary patch delta 1381 zcmaFPzE)_1Av50w9tMW=f^nC%u82rOi#@#QP40lFf`Fruu07+NGt}*IDi;>>3OAk`9C z6H{b4<)XvzQ@rG3edNsz?*6RJ^?TpXW@U=mUz*7z&CJTlna0?_%FW5aUeClP%E8IS z&BP+c#LUPf$H*k!z`(^R0Mpa+lHq?)vdzxY+t0W+>VA3<;&nLp=59UBlr-aeS0^9y z_xk@vn&E$NVMn^|k*06kdxV1;78fsS$h-8i-sp^-P{WmrGUjoe8=$_N$=J&hvp<82 zk%!?__cHbB&nES+?l3R+KRY|4rc)%Sc=ieImVFC$tj=;TP>__?V^Ey0kmHg6FLlOl z_cH<+ALDj(t&q`(`LNVTV!pw)Ti#t0X3bgrCn>q8v}D#dnJT_^ey-+{y=o_(IXODa z2&s&$$orrglb|{+a@MIIg|)K(+M+IQJ^i$cQ{hO{!Ot%JHXg5^)N4MjK9$68@NBlj znED|I((oZ{x#X}UE|RXE*bMV~eQJ*6U*)+hJ5O$G0SZmrMr7v1}``*Ka$ zqpz`ouMBPmEIZiWZ=)!WRH@kmoPAlL3N7SHb`5diP=hNKIKM(zC zQvPvsDXV$jXSGZ7joVI!{YVwQP`EEba9!f6?GvZGSp9P;--nxL#4NrfPK)vtT*2{W zp1judDQ{(y{2xu*{MW}~bAQ5>C+030|1-`y-mAZEeNtX~)11$-<&SP$O}x$^$jDI7 zh?-3CrbA02(_ts$6&7JeNJ2bf9O|BS`R*|%#r><;a@U`3e4^t3N{A)d;DlJunZ{!R zPKh`YB23R*0q%e1Dbmv?9iF^WX_{O@?9&9VsJ4S!0&*~p(;dq?)Sheu6+?$|2SrguR8n1yzfqO4`USj0`` zhfMEtSqzTo>m^r9nx_|pIqHgCZ*i7hGJUn!C!<8;)YN5JF&4^dTROLNRT+kfwg^36 zwaDq(ox;eJ{t1#n;e3w*nLljkoHeUnXK$ZN?VppKolem;@=Ne7vK26!c_D<%d9h2Bdm9` zZ$j~m^8Y*c?h8%ZqO8)k$T$6s+9iF3vzB}0OFcGsF)mr#?!PAGO5sBHpgxsZZdZDL z)eGm?RDIaGs$a;H^X7Y*$2%T-mvJv|mZ)teSum4TY*WNmj@=0{woZa5A zoZL~$A^