From 850971d68cdfbf8d22986e03ae73ba37cb178d6c Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 26 Jan 2018 13:56:19 +0100 Subject: [PATCH] a lot of fixes. mostly related to byte compile. - fixed copyright-update hook. You can toggle it now. - create ticket directory if it doesn't exist. - fix for eshell ll. Signed-off-by: Andreas Gerler --- bba.org | 351 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 205 insertions(+), 146 deletions(-) diff --git a/bba.org b/bba.org index c9f6450f..6900b695 100644 --- a/bba.org +++ b/bba.org @@ -1,4 +1,4 @@ -# -*- 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 @@ -198,13 +198,14 @@ Want to have some [[http://www.emacswiki.org/emacs/EshellAlias][shell aliases]], 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? @@ -287,9 +288,9 @@ For annotated tags prepare message with commit messages since last tag. (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)) ) ) ) @@ -312,13 +313,13 @@ focus on the important stuff. * 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 @@ -500,7 +501,7 @@ snippets for =aws cli= are awesome! (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) @@ -550,12 +551,6 @@ Default to snippet-mode if we are in a sub directory of snippets: (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] @@ -587,6 +582,12 @@ Languages differ and I need different templates. * [[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. @@ -629,6 +630,10 @@ 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. @@ -695,15 +700,16 @@ Use [[http://orgmode.org/manual/A-LaTeX-example.html#A-LaTeX-example][orgtbl]] t 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 @@ -910,11 +916,16 @@ We are lazy and want to speed up things: (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) @@ -927,31 +938,33 @@ never heard of orgmode. #+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 @@ -959,9 +972,9 @@ never heard of orgmode. #+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))) ) @@ -972,25 +985,29 @@ never heard of orgmode. [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 @@ -1097,48 +1114,48 @@ This is helpful in training sessions. 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() @@ -1221,11 +1238,11 @@ Here is the code: (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 @@ -1411,10 +1428,26 @@ taken from http://doc.norang.ca/org-mode.org (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. @@ -1631,7 +1664,7 @@ to embed videos, they give you the entire iframe HTML code to use, but 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 "