-# -*- org-export-babel-evaluate: nil; -*-
+# -*- org-export-use-babel: nil; -*-
#+SETUPFILE: ~/git/github/org-html-themes/setup/theme-bigblow-local.setup
#+STARTUP: showall
#+TITLE: bba emacs configuration
Some of my favorite bash aliases, can be even more helpful in Eshell. Like ‘ll’:
#+BEGIN_SRC elisp :tangle yes
+ (require 'em-alias)
(add-hook 'eshell-mode-hook
(lambda ()
;; The 'ls' executable requires the Gnu version on the Mac
(let ((ls (if (file-exists-p "/opt/local/bin/gls")
"/opt/local/bin/gls"
"/bin/ls")))
- (eshell/alias "ll" (concat ls " -AlohG --color=always")))))
+ (add-to-list 'eshell-command-aliases-list (list "ll" (concat ls " -AlohG --color=always") )))))
#+END_SRC
What about =gd= to call the Diff command?
(progn
(insert (shell-command-to-string "git log --pretty=format:\"* %s\" `git rev-list --tags --max-count=1`..HEAD" ))
(newline)
- (beginning-of-buffer)
+ (goto-char (point-min))
(newline)
- (beginning-of-buffer)
+ (goto-char (point-min))
)
)
)
* fullframe
open ibuffer and magit-status in fullframe mode.
-#+BEGIN_SRC emacs-lisp :tangle yes
- (if (>= emacs-major-version 24)
+#+BEGIN_SRC emacs-lisp :tangle no
+ (if (>= emacs-major-version 25)
(progn
(add-to-list 'load-path "~/.emacs.d/elpa/fullframe-20160209.2318")
(require 'fullframe)
(fullframe magit-status magit-mode-quit-window)
- (fullframe ibuffer ibuffer-quit)
+ (fullframe ibuffer)
)
)
#+END_SRC
(if (equal "work" (getenv "SYSENV"))
(add-to-list 'yas-snippet-dirs "~/workorg/snippets"))
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")
- (yas/reload-all)
+ (yas-reload-all)
(yas-global-mode 1)
(setq yas-indent-line nil)
(setq yas-triggers-in-field t)
(add-to-list 'auto-mode-alist '("\\.emacs.d/snippets/[^/]*/" . snippet-mode))
#+END_SRC
-We use lisp in our snippets. So suppress warnings for that:
-
-#+BEGIN_SRC emacs-lisp :tangle yes
- (add-to-list 'warning-suppress-types '(yasnippet backquote-change))
-#+END_SRC
-
* define some major modes for yasnippets
[2016-05-25 Wed 10:26]
* [[https://github.com/flycheck/flycheck][flycheck]]
+To get puppet-lint:
+
+#+BEGIN_SRC sh :tangle never
+ gem install puppet-lint
+#+END_SRC
+
modified puppet-lint definition to include no-80chars-check and fixed
log-format.
)
)
#+END_SRC
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (setq flycheck-json-python-json-executable "python2.7")
+#+END_SRC
* [[https://github.com/kai2nenobu/guide-key][guide-key]]
Probably the best help to keep track of the not every day used keybindings.
Adjust indentation at work.
#+BEGIN_SRC emacs-lisp :tangle yes
- ;; load yaml-mode
- ;; (require 'yaml-mode)
- ;; (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
+ ;; load yaml-mode
+ ;; (require 'yaml-mode)
+ ;; (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
+ (defvar bba-keep-whitespaces)
(if (equal "work" (getenv "SYSENV"))
(setq yaml-indent-offset 4))
(add-hook 'yaml-mode-hook
(lambda()
(auto-fill-mode -1)
- (setq bba-keep-whitespaces 1)))
+ (setq bba-keep-whitespaces 1)))
#+END_SRC
(interactive)
(org-narrow-to-subtree)
(bba-export-jira-org)
- (let ((org-export-babel-evaluate nil))
+ (let ((org-export-use-babel nil))
(ox-jira-export-as-jira))
(delete-region (point) (progn (forward-line 1)(point)))
- (mark-whole-buffer)
+ (push-mark (point))
+ (push-mark (point-max) nil t)
+ (goto-char (point-min))
(kill-ring-save 1 1 1)
+ (other-window -1)
+ (widen)
+ (other-window 1)
)
(define-key org-mode-map "\C-c\S-j" 'bba-org-export-jira-clipboard)
#+BEGIN_SRC emacs-lisp :tangle yes
(defun bba-export-jira-org()
- "export current narrowed view to file in tmp and open a finder window on OS-X."
- (interactive)
- (beginning-of-buffer)
- (insert "# This file is just plain text called orgmode")
- (newline)
- (insert "# https://en.wikipedia.org/wiki/Org-mode")
- (newline)
- (insert "# You can open it in any text editor or file reader.")
- (newline)
- (insert "# You might want to use Emacs for best experience.")
- (newline)
- (if (re-search-forward "jira:" nil t 1)
- (if (org-in-regexp org-bracket-link-regexp 1)
- (let ((remove (list (match-beginning 0) (match-end 0)))
- (description (last (split-string (if (match-end 3)
- (match-string-no-properties 3)
- (match-string-no-properties 1)) ":"))))
- (mark-whole-buffer)
- (write-region (mark) (point) (concat "/tmp/" (car description) ".org") nil nil )
- (deactivate-mark)
- (if (string-equal system-type "darwin")(shell-command "open /tmp/"))
- )))
- (beginning-of-buffer)
- (kill-line 4)
- )
+ "export current narrowed view to file in tmp and open a finder window on OS-X."
+ (interactive)
+ (goto-char (point-min))
+ (insert "# This file is just plain text called orgmode")
+ (newline)
+ (insert "# https://en.wikipedia.org/wiki/Org-mode")
+ (newline)
+ (insert "# You can open it in any text editor or file reader.")
+ (newline)
+ (insert "# You might want to use Emacs for best experience.")
+ (newline)
+ (if (re-search-forward "jira:" nil t 1)
+ (if (org-in-regexp org-bracket-link-regexp 1)
+ (let ((remove (list (match-beginning 0) (match-end 0)))
+ (description (last (split-string (if (match-end 3)
+ (match-string-no-properties 3)
+ (match-string-no-properties 1)) ":"))))
+ (push-mark (point))
+ (push-mark (point-max) nil t)
+ (goto-char (point-min))
+ (write-region (mark) (point) (concat "/tmp/" (car description) ".org") nil nil )
+ (deactivate-mark)
+ (if (string-equal system-type "darwin")(shell-command "open /tmp/"))
+ )))
+ (goto-char (point-min))
+ (kill-line 4)
+ )
#+END_SRC
** bba-ox-clip-formatted-copy
#+BEGIN_SRC emacs-lisp :tangle yes
(defun bba-ox-clip-formatted-copy()
- "wrapper for ox-clip-formatted-copy to disable org-export-babel-evaluate."
+ "wrapper for ox-clip-formatted-copy to disable org-export-use-babel."
(interactive)
- (let ((org-export-babel-evaluate nil))
+ (let ((org-export-use-babel nil))
(ox-clip-formatted-copy (mark) (point)))
)
[2017-07-28 Fri 13:07]
#+BEGIN_SRC emacs-lisp :tangle yes
- (defun bba-create-ticket-tmp-dir()
- "create directory for the current ticket in tmp."
+ (defun bba-create-ticket-tmp-dir-open-dir-screen()
+ "Create directory for the current ticket in tmp if not exist.
+ Open the directory of the current ticket in iterm screen via keyboard maestro."
(interactive)
(org-narrow-to-subtree)
(let ((beg (point)))
- (beginning-of-buffer)
+ (goto-char (point-min))
(if (re-search-forward "jira:" nil t 1)
- (if (org-in-regexp org-bracket-link-regexp 1)
- (let ((remove (list (match-beginning 0) (match-end 0)))
- (description (last (split-string (if (match-end 3)
- (match-string-no-properties 3)
- (match-string-no-properties 1)) ":"))))
- (unless (file-exists-p (concat "~/tmp/" (downcase (car description))))
- (mkdir (concat "~/tmp/" (downcase (car description))))
- ))))
+ (if (org-in-regexp org-bracket-link-regexp 1)
+ (let ((remove (list (match-beginning 0) (match-end 0)))
+ (description (last (split-string (if (match-end 3)
+ (match-string-no-properties 3)
+ (match-string-no-properties 1)) ":"))))
+ (unless (file-exists-p (concat "~/tmp/" (downcase (car description))))
+ (mkdir (concat "~/tmp/" (downcase (car description))))
+ )
+ (kill-new (concat "~/tmp/" (downcase (car description))))
+ )))
(goto-char beg)
)
(widen)
- )
+ (shell-command "osascript -e \'tell app \"Keyboard Maestro Engine\" to do script \"screen-start-cd-to-clipboard\"'")
+ )
#+END_SRC
** Some initial languages we want org-babel to support
If region is active copy only the src begin and src end lines."
(interactive)
(if (use-region-p)
- (progn
- (let (-p1 -p2 srclength)
- (setq -p1 (region-beginning) -p2 (region-end))
- (setq mark-active nil)
- (re-search-backward "\#\\+BEGIN_SRC")
- (previous-line)
+ (progn
+ (let (-p1 -p2 srclength)
+ (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))
- (set-mark-command nil)
- (forward-line)
- (beginning-of-line)
- (kill-ring-save 1 1 1)
- (goto-char -p1)
- (set-mark-command nil)
- (insert (pop kill-ring))
- (setq srclength (- (region-end) (region-beginning)))
- (setq mark-active nil)
- (re-search-backward "\#\\+END_SRC")
- (set-mark-command nil)
- (forward-line)
- (beginning-of-line)
- (kill-ring-save 1 1 1)
- (kill-append "\n" nil)
- (goto-char (+ -p2 srclength))
- (insert (pop kill-ring))
- )
- )
+ (set-mark-command nil)
+ (forward-line)
+ (beginning-of-line)
+ (kill-ring-save 1 1 1)
+ (goto-char -p1)
+ (set-mark-command nil)
+ (insert (pop kill-ring))
+ (setq srclength (- (region-end) (region-beginning)))
+ (setq mark-active nil)
+ (re-search-backward "\#\\+END_SRC")
+ (set-mark-command nil)
+ (forward-line)
+ (beginning-of-line)
+ (kill-ring-save 1 1 1)
+ (kill-append "\n" nil)
+ (goto-char (+ -p2 srclength))
+ (insert (pop kill-ring))
+ )
+ )
(progn
- (push-mark)
- (re-search-backward "\#\\+BEGIN_SRC")
- (previous-line)
+ (push-mark)
+ (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)
- (beginning-of-line)
- (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)
- ))
+ (set-mark-command nil)
+ (re-search-forward "\#\\+END_SRC")
+ (forward-line)
+ (beginning-of-line)
+ (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()
(shell-command "tmuxhardcopy.sh")
(insert "#+END_SRC")
(newline)
- (previous-line 2)
+ (forward-line -2)
(org-edit-special)
(delete-trailing-whitespace)
(org-edit-src-exit)
- (next-line 2)
+ (forward-line 2)
)
#+END_SRC
(setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
;; Include current clocking task in clock reports
(setq org-clock-report-include-clocking-task t)
- (setq org-time-clocksum-format
+ (setq org-duration-format
'(:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t))
(setq bh/keep-clock-running nil)
+ (defun bh/is-project-p ()
+ "Any task with a todo keyword subtask"
+ (save-restriction
+ (widen)
+ (let ((has-subtask)
+ (subtree-end (save-excursion (org-end-of-subtree t)))
+ (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
+ (save-excursion
+ (forward-line 1)
+ (while (and (not has-subtask)
+ (< (point) subtree-end)
+ (re-search-forward "^\*+ " subtree-end t))
+ (when (member (org-get-todo-state) org-todo-keywords-1)
+ (setq has-subtask t))))
+ (and is-a-task has-subtask))))
+
(defun bh/clock-in-to-next (kw)
"Switch a task from TODO to NEXT when clocking in.
Skips capture tasks, projects, and subprojects.
this wouldn’t really be Emacs if we couldn’t make things just a little
bit easier.
-#+BEGIN_SRC emacs-lisp :tangle yes
+#+BEGIN_SRC emacs-lisp :tangle never
(defvar yt-iframe-format
;; You may want to change your width and height.
(concat "<iframe width=\"440\""
#+BEGIN_SRC emacs-lisp :tangle yes
;; put your css files there
(defvar org-theme-css-dir "~/.emacs.d/org-css/")
+ (defvar org-theme-css)
(defun toggle-org-custom-inline-style ()
(interactive)
(set (make-local-variable 'org-html-head-include-default-style)
nil)
(message "Set custom style from %s" f))
- (message "Custom header file %s doesnt exist")))))
+ (message "Custom header file %s doesnt exist" f)))))
#+END_SRC
** org-sticky-header
(defun load-git-cfengine ()
"Load config and tags file of git cfengine repo"
(interactive) (visit-tags-table "~/.cfengine_tags")
- (interactive) (find-file "~/.cfagent/inputs/config.cf")
+ (find-file "~/.cfagent/inputs/config.cf")
)
;; cfe-config-adduser-ldap runs ldapsearch with cn=user to fill some values.
#+BEGIN_SRC emacs-lisp :tangle yes
;; Do not use gpg agent when runing in terminal
+ (if (>= emacs-major-version 25)
(defadvice epg--start (around advice-epg-disable-agent activate)
(let ((agent (getenv "GPG_AGENT_INFO")))
(when (not (display-graphic-p))
(setenv "GPG_AGENT_INFO" nil))
ad-do-it
(when (not (display-graphic-p))
- (setenv "GPG_AGENT_INFO" agent))))
+ (setenv "GPG_AGENT_INFO" agent)))))
;; (defadvice epg--start (around advice-epg-disable-agent disable)
;; "Don't allow epg--start to use gpg-agent in plain text terminals."
(defun bba-epa-list-packets ()
"List who can decrypt the current file"
(interactive)
- (let ((bba-epa-filename (buffer-file-name)))
- (setq bba-epa-packets-buffer (generate-new-buffer "*Packets*"))
+ (let ((bba-epa-filename (buffer-file-name))
+ (bba-epa-packets-buffer (generate-new-buffer "*Packets*")))
(set-buffer bba-epa-packets-buffer)
(insert (shell-command-to-string (concat "gpg --list-packets " bba-epa-filename))
;; (epg--start context "--list-packets ")
(setq abbrev-file-name "~/org/abbrev_defs")
(if (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file))
- (setq default-abbrev-mode t)
+ (set-default 'abbrev-mode t)
+ (abbrev-mode )
(setq save-abbrevs 'silently)
#+END_SRC
thanks to https://truongtx.me/2014/08/23/setup-emacs-as-an-sql-database-client
-#+BEGIN_SRC emacs-lisp
+have a look in [[file:/Applications/Emacs.app/Contents/Resources/lisp/progmodes/sql.el.gz::(let%20((connect-set%20(assoc-string%20connection%20sql-connection-alist%20t)))][sql.el]] and extract the sql-product and set it before
+starting sql-connect.
+
+#+BEGIN_SRC emacs-lisp :tangle yes
(defun my-sql-connect ()
(interactive)
(require 'my-password "~/.emacs_secrets.el.gpg")
(setq sql-product 'vertica)
-
(let ((connection (helm-comp-read
"Select server: "
my-sql-servers-alist
With modifications by [[http://sachachua.com/blog/2011/12/emacs-artbollocks-mode-el-and-writing-more-clearly/][Sacha Chua]].
#+BEGIN_SRC emacs-lisp :tangle yes
- (if (>= emacs-major-version 24)
+ (if (>= emacs-major-version 25)
(progn
(require 'artbollocks-mode)
;; Avoid these phrases
(defun bba-insert-date ()
"Insert the current date"
(interactive)
- (insert-string (format-time-string "%B %e, %Y")))
+ (insert (format-time-string "%B %e, %Y")))
(defun bba-insert-timestamp ()
"Insert the current timestamp"
(interactive)
- (insert-string (format-time-string "%Y%m%d-%H%M")))
+ (insert (format-time-string "%Y%m%d-%H%M")))
(defun bba-insert-name-timestamp ()
"Insert the current timestamp"
(interactive)
- (insert-string (format-time-string "%a %b %e %Y") " " (or (and (boundp 'user-full-name) user-full-name) (user-full-name))" <" (getenv "EMAIL") ">" ))
+ (insert (format-time-string "%a %b %e %Y") " " (or (and (boundp 'user-full-name) user-full-name) (user-full-name))" <" (getenv "EMAIL") ">" ))
(defun bba-insert-name ()
"Insert name and emailaddress of current systemuser."
(interactive)
- (insert-string (or (and (boundp 'user-full-name) user-full-name) (user-full-name))" <" (getenv "EMAIL") ">" ))
+ (insert (or (and (boundp 'user-full-name) user-full-name) (user-full-name))" <" (getenv "EMAIL") ">" ))
(define-key global-map (kbd "s-n") 'bba-insert-name)
(define-key bba/toggle "a" 'artbollocks-mode)
(define-key bba/toggle "b" 'bba-switch-default-browser)
(define-key bba/toggle "c" 'rainbow-mode)
+ (define-key bba/toggle "\S-c" 'bba-toggle-copyright-update)
(define-key bba/toggle "e" 'eldoc-mode)
(define-key bba/toggle "\S-e" 'epoch-view-mode)
(define-key bba/toggle "f" 'auto-fill-mode)
(define-key bba/keyboard-maestro "s" 'bba-screen-start-ssh-to-fqdn-at-point)
(define-key bba/keyboard-maestro "c" 'bba-open-file-dir-screen)
+ (define-key bba/keyboard-maestro "C" 'bba-create-ticket-tmp-dir-open-dir-screen)
(define-key bba/multiple-cursors "e" 'mc/edit-lines)
(define-key bba/multiple-cursors "m" 'mc/mark-all-like-this)
update copyrights
#+BEGIN_SRC emacs-lisp :tangle yes
- (add-hook 'before-save-hook 'copyright-update)
+ (defvar bba-copyright-update 't)
+ (defun bba-toggle-copyright-update()
+ "switch copyright-update on save on or off."
+ (interactive)
+ (if (bound-and-true-p bba-copyright-update)
+ (setq bba-copyright-update nil)
+ (setq bba-copyright-update t))
+ (message "copyright-update is %s" bba-copyright-update)
+ )
+ (add-hook 'before-save-hook (lambda()
+ (if (bound-and-true-p 'bba-copyright-update)
+ (copyright-update))))
+#+END_SRC
#+END_SRC
* other stuff
(global-set-key '[(end)] 'chb-end)
;;
(defun chb-home ()
- (interactive)
- (setq zmacs-region-stays t)
- (if (not (bolp))
- (beginning-of-line)
- (if (eq this-command last-command)
- (cond
- ((not (= (point) (window-start)))
- (move-to-window-line 0)
- (beginning-of-line))
- (t
- (goto-char (point-min)))))))
+ (interactive)
+ (if (not (bolp))
+ (beginning-of-line)
+ (if (eq this-command last-command)
+ (cond
+ ((not (= (point) (window-start)))
+ (move-to-window-line 0)
+ (beginning-of-line))
+ (t
+ (goto-char (point-min)))))))
(defun chb-end ()
- (interactive)
- (setq zmacs-region-stays t)
- (if (not (eolp))
- (end-of-line)
- (if (eq this-command last-command)
- (cond
- ((not (= (point) (save-excursion
- (move-to-window-line -1)
+ (interactive)
+ (if (not (eolp))
+ (end-of-line)
+ (if (eq this-command last-command)
+ (cond
+ ((not (= (point) (save-excursion
+ (move-to-window-line -1)
(end-of-line)
(point))))
(move-to-window-line -1)
(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"))))
+ '(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"))
((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
`(org-level-3 ((t (,@headline ,@variable-tuple :height 1.25))))
`(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))))))
- ))
+ `(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"]))
+ )))
#+END_SRC
#+BEGIN_SRC emacs-lisp :tangle yes
(if (string-equal system-type "darwin")
- (set-default-font "Menlo 14"))
+ (set-frame-font "Menlo 12"))
#+END_SRC
* dns-mode
)
- (add-hook 'dns-mode-hook
- (lambda ()
- (define-key dns-mode-map "\C-c\C-r" 'dns-rndc)
- ))
+ (eval-after-load 'dns-mode
+ (add-hook 'dns-mode-hook
+ (lambda ()
+ (define-key dns-mode-map "\C-c\C-r" 'dns-rndc)
+ )))
#+END_SRC
(switch-to-buffer (concat "*aws-" profile "-" name "*"))
(org-mode)
(message "querying aws for %s in profile %s" name profile)
- (insert-string (shell-command-to-string (concat "aws ec2 describe-instances --profile " profile " --filters \"Name=tag-key,Values=Name,Name=tag-value,Values=" name "*\" --query \"Reservations[].Instances[?State.Name=='running'].[InstanceId, PublicDnsName]\" --output table")))
+ (insert (shell-command-to-string (concat "aws ec2 describe-instances --profile " profile " --filters \"Name=tag-key,Values=Name,Name=tag-value,Values=" name "*\" --query \"Reservations[].Instances[?State.Name=='running'].[InstanceId, PublicDnsName]\" --output table")))
(message "done.")
)
(progn (split-window-below)
(other-window 1)
(find-file "~/org/workhours.org")
- (beginning-of-buffer)
+ (goto-char (point-min))
(org-shifttab 3)
(if (re-search-forward (concat "^\*\* "(format-time-string "%Y-%m")) nil t)
(org-beginning-of-line)
(progn
- (beginning-of-buffer)
+ (goto-char (point-min))
(org-next-visible-heading '1)
(org-meta-return)
(insert (format-time-string "%Y-%m"))