https://orgmode.org/manual/Structure-Templates.html
(require 'org-tempo)
Check out other people’s configs and read through them, learn about nifty things and add to your own. https://github.com/munen/emacs.d/
https://github.com/purcell/emacs.d
And even better: follow this list of configs: https://github.com/caisah/emacs.dz
Sacha Chua would be good.
<2018-07-11 Wed 10:36> I started looking through some. I guess I can just pick stuff here and there.
This shows only the first 9 characters of the branch name and the lock/whatever symbol (“:” or “-“) Mostly got it from this answer: https://emacs.stackexchange.com/questions/10955/customize-vc-mode-appearance-in-mode-line Helpful for understanding advice and eval.
(setcdr (assq 'vc-mode mode-line-format)
'((:eval (truncate-string-to-width (replace-regexp-in-string "^ Git" "" vc-mode) 10))))
https://www.emacswiki.org/emacs/NoTabs
(setq-default indent-tabs-mode nil)
;; Emacs lisp files
(add-to-list 'load-path "~/.emacs.d/elisp/")
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(use-package magit)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-always-ensure t)
(setq use-package-verbose t)
(require 'use-package)
Here is the stack answer about using the ‘some’ function.
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(C . t)))
(defun my-org-confirm-babel-evaluate (lang body)
(not (or
(member lang '("python"))
(member lang '("emacs-lisp"))
(member lang '("C++"))
))
)
(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
(use-package iedit
:defer t
)
(require 'iedit)
;(require 'flycheck-pyflakes)
;(add-hook 'python-mode-hook 'flycheck-mode)
;(add-to-list 'flycheck-disabled-checkers 'python-flake8)
;(add-to-list 'flycheck-disabled-checkers 'python-pylint)
;I had to reinstall concurrent to get this to work.
;(use-package jedi
;:ensure t
;:init
;(add-hook 'python-mode-hook 'jedi:setup)
;(add-hook 'python-mode-hook 'jedi:ac-setup))
; Enable execution of code blocks.
;; (org-babel-do-load-languages
;; 'org-babel-load-languages
;; '((python . t)))
(add-hook 'python-mode-hook 'linum-mode)
(setq python-indent-offset 4)
;path for virtual environments.
;; (add-dir-local-variable $WORKON_HOME 'C:\Users\PayneFamily\Dropbox\Python\envs')
;(require 'virtualenvwrapper)
;(venv-initialize-interactive-shells) ;; if you want interactive shell support
;(venv-initialize-eshell) ;; if you want eshell support
;; note that setting `venv-location` is not necessary if you
;; use the default location (`~/.virtualenvs`), or if the
;; the environment variable `WORKON_HOME` points to the right place
; Activate elpy automatically
(require 'package)
(package-initialize)
(elpy-enable)
(add-hook 'python-mode-hook 'blacken-mode)
;; Setting line length to 100 for team agreement.
(setq blacken-line-length 100)
;TODO set up again
;(setq elpy-rpc-python-command "~/Envs/.emacs.d-GQXW7O1A/bin/python3")
;(pyvenv-activate "/Users/apayne/Envs/.emacs.d-GQXW7O1A")
; I disabled this because it runs way too slow on remote machines. And just it runs too slow.
;(add-hook 'after-init-hook #'global-flycheck-mode)
(use-package pipenv
:hook (python-mode . pipenv-mode)
:init
(setq
pipenv-projectile-after-switch-function
#'pipenv-projectile-after-switch-extended))
;; Configure flymake for Python
(when (load "flymake" t)
(defun flymake-pylint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "epylint" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))
;; Set as a minor mode for Python
(add-hook 'python-mode-hook '(lambda () (flymake-mode)))
https://tuhdo.github.io/c-ide.html
;; if the files are not already in the load path
;; (add-to-list 'load-path "folder-to/visual-regexp/")
;; (add-to-list 'load-path "folder-to/visual-regexp-steroids/")
(use-package visual-regexp-steroids)
(require 'visual-regexp-steroids)
(define-key global-map (kbd "C-c r") 'vr/replace)
(define-key global-map (kbd "C-c q") 'vr/query-replace)
;; if you use multiple-cursors, this is for you:
(use-package multiple-cursors)
(require 'multiple-cursors)
(define-key global-map (kbd "C-c m") 'vr/mc-mark)
;; to use visual-regexp-steroids's isearch instead of the built-in regexp isearch, also include the following lines:
(define-key esc-map (kbd "C-r") 'vr/isearch-backward) ;; C-M-r
(define-key esc-map (kbd "C-s") 'vr/isearch-forward) ;; C-M-s
This keeps undo history for window layouts. It will be useful if for some reason a package removes windows. C-c <left> undo C-c <right redo
(winner-mode 1)
; Testing
(if (file-exists-p "~/.emacs.d/robot-mode/robot-mode.el") (load-file "~/.emacs.d/robot-mode/robot-mode.el"))
(add-to-list 'auto-mode-alist '("\\.robot\\'" . robot-mode))
;; Shortut for making allignment look good. Doesn't work very well.
;(global-set-key (kbd "C-c a") (align-regexp (point-min) (point-max) "^\w.*[[:space:]]\{2,\}"))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'tooltip-mode) (tooltip-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
; This changes the title to the path of the file of the current buffer.
(when window-system
(setq frame-title-format '(buffer-file-name org-clock-current-task buffer-file-name " %f" ("%b")))
(add-hook 'window-setup-hook 'toggle-frame-maximized t))
I borrowed these from someone else.
(defun smarter-move-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.
If ARG is not nil or 1, move forward ARG - 1 lines first. If
point reaches the beginning or end of the buffer, stop there."
(interactive "^p")
(setq arg (or arg 1))
;; Move lines first
(when (/= arg 1)
(let ((line-move-visual nil))
(forward-line (1- arg))))
(let ((orig-point (point)))
(back-to-indentation)
(when (= orig-point (point))
(move-beginning-of-line 1))))
(global-set-key (kbd "C-a") 'smarter-move-beginning-of-line)
(defun my/switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(global-set-key (kbd "C-c t")
(lambda () (interactive) (org-time-stamp "HH:MM")))
(global-set-key (kbd "C-c p")
(lambda () (interactive) (find-file "~/Dropbox/WebDev/Ob.org")))
(global-set-key (kbd "C-c d") ; d for Daily
(lambda () (interactive) (find-file "~/Dropbox/WebDev/DailyGoalSetting.org")))
(global-set-key (kbd "C-c e") ; e for Employment
(lambda () (interactive) (find-file "~/Dropbox/Org/Work.org")))
(global-set-key (kbd "C-c w") ; w for What a ton of fun! Personal Projects
(lambda () (interactive) (find-file "~/Dropbox/WebDev/Projects.org")))
(global-set-key (kbd "C-c k") ; k for knowledge base
(lambda () (interactive) (find-file "~/Dropbox/Org/KB.org")))
;; Open this config file
(global-set-key (kbd "C-c s") ; s for Settings
(lambda () (interactive) (find-file "~/.emacs.d/settings.org")))
(defun my/switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(windmove-default-keybindings)
;; Make windmove work in org-mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)
From Daniel Mai https://github.com/danielmai/.emacs.d/blob/master/config.org
(defun vsplit-other-window ()
"Splits the window vertically and switches to that window."
(interactive)
(split-window-vertically)
(other-window 1 nil))
(defun hsplit-other-window ()
"Splits the window horizontally and switches to that window."
(interactive)
(split-window-horizontally)
(other-window 1 nil))
(bind-key "C-x 2" 'vsplit-other-window)
(bind-key "C-x 3" 'hsplit-other-window)
This is cool! I never knew this was here.
(use-package hydra)
(defhydra hydra-resize (global-map "<f2>")
"resizing hydra"
("<left>" shrink-window-horizontally "shrink horizontal")
("<right>" enlarge-window-horizontally "enlarge horizontal")
("<down>" shrink-window "shrink")
("<up>" enlarge-window "shrink")
)
(defun es/switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(use-package key-chord
:init
(progn
(key-chord-mode 1)
(key-chord-define-global "GG" 'magit-status)
;; Someday I'll look into what these other ones are and try them out.
; (key-chord-define-global ";f" 'flip-frame)
; (key-chord-define-global ";t" 'elpy-test-pytest-runner)
; (key-chord-define-global "jj" 'helm-projectile-find-file)
; (key-chord-define-global "JJ" 'helm-projectile-find-file-in-known-projects)
(key-chord-define-global "BB" 'my/switch-to-previous-buffer)
; (key-chord-define-global "\\\\" 'es/helm-mini-or-projectile-find-file)
; (key-chord-define-global "MM" 'hydra-modes/body)
;; (key-chord-define-global "FF" 'delete-other-windows)
;; (key-chord-define-global "SS" 'helm-swoop-back-to-last-point) ;;I type SS too much.
;; (key-chord-define-global "DD" 'dired-jump)
)
)
;; (use-package monokai-theme
;; :init
;; (load-theme 'monokai t)
;; )
;; THEME switching stuff from Daniel Mai
(defun switch-theme (theme)
"Disables any currently active themes and loads THEME."
;; This interactive call is taken from `load-theme'
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapc 'symbol-name
(custom-available-themes))))))
(let ((enabled-themes custom-enabled-themes))
(mapc #'disable-theme custom-enabled-themes)
(load-theme theme t)))
(defun disable-active-themes ()
"Disables any currently active themes listed in `custom-enabled-themes'."
(interactive)
(mapc #'disable-theme custom-enabled-themes))
(bind-key "C-`" 'switch-theme)
(use-package zenburn-theme)
(load-theme `zenburn t)
(use-package helpful)
(require 'helpful)
;; Note that the built-in `describe-function' includes both functions
;; and macros. `helpful-function' is functions only, so we provide
;; `helpful-callable' as a drop-in replacement.
(global-set-key (kbd "C-h f") #'helpful-callable)
(global-set-key (kbd "C-h v") #'helpful-variable)
(global-set-key (kbd "C-h k") #'helpful-key)
;; Lookup the current symbol at point. C-c C-d is a common keybinding
;; for this in lisp modes.
(global-set-key (kbd "C-c C-d") #'helpful-at-point)
;; Look up *F*unctions (excludes macros).
;;
;; By default, C-h F is bound to `Info-goto-emacs-command-node'. Helpful
;; already links to the manual, if a function is referenced there.
(global-set-key (kbd "C-h F") #'helpful-function)
;; Look up *C*ommands.
;;
;; By default, C-h C is bound to describe `describe-coding-system'. I
;; don't find this very useful, but it's frequently useful to only
;; look at interactive functions.
(global-set-key (kbd "C-h C") #'helpful-command)
;; I don't want any visual or audible alarm when I am scrolling or anything happens.
(setq ring-bell-function 'ignore)
Still don’t know what this does. TODO: Make it so helm doesn’t take over th
(use-package helm-ag
:defer t
:config
(setq helm-ag-insert-at-point 'symbol)
)
(use-package helm
:init
(require 'helm-config)
(helm-mode 1)
(setq helm-recentf-fuzzy-match t
helm-buffers-fuzzy-matching t
helm-completion-in-region-fuzzy-match t
helm-mode-fuzzy-match t
helm-recentf-fuzzy-match t
helm-M-x-fuzzy-match t)
(add-to-list 'helm-completing-read-handlers-alist '(find-file . helm-completing-read-symbols))
:bind (("C-x b" . helm-mini)
("C-x f" . helm-recentf)
("C-s" . helm-occur)
("M-x" . helm-M-x)
("M-y" . helm-show-kill-ring)))
(define-key helm-map
(kbd "<down-mouse-2>") 'mouse-yank-primary)
(define-key helm-map
(kbd "<drag-mouse-2>") 'ignore)
(defun es/helm-mini-or-projectile-find-file ()
(interactive)
(if (helm-alive-p)
(helm-run-after-exit #'helm-projectile-find-file)
(helm-mini)))
http://stackoverflow.com/questions/7174819/export-effort-and-clocksum-from-org-mode
(setq org-refile-targets '((org-agenda-files . (:maxlevel . 6))))
(setq org-hide-leading-stars t)
; http://stackoverflow.com/questions/7174819/export-effort-and-clocksum-from-org-mode
(setq org-export-with-drawers t)
(setq org-export-with-properties t)
(setq org-export-with-priority t)
(setq org-export-with-toc nil)
(setq org-export-with-section-numbers 1)
;; (defun jbd-org-export-format-drawer (name content)
;; "Export drawers to drawer HTML class."
;; (setq content (org-remove-indentation content))
;; (format "@<div class=\"drawer\">%s@</div>\n" content))
(add-hook 'org-mode-hook 'org-indent-mode)
;; (setq org-export-format-drawer-function 'jbd-org-export-format-drawer)
;;I use visual line mode in org mode because I do so much writing in my org files.
(add-hook 'org-mode-hook 'visual-line-mode)
;; Open .org and .txt files in org-mode
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
(add-hook 'org-agenda-finalize-hook
(lambda () (remove-text-properties
(point-min) (point-max) '(mouse-face t))))
; This is supposed to include the current open clock in reports.
; It presently isn't working like I expect. I don't see it doing anything.
(setq org-clock-report-include-clocking-task 1)
; I was using this. I think it was useful but I'm not sure what it does exactly.
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
;; I like to see the total hours in my clocks instead of cumulative days.
(setq org-time-clocksum-format (quote (:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t)))
;; Insert the Closed string with the timestamp of when the task was marked "Done"
(setq org-log-done 'time)
;; Another option:
;;(setq org-log-done 'note)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'corgi-org-agenda)
;; bindings for capture templates
(define-key global-map "\C-ci" ;inbox
(lambda () (interactive) (org-capture nil "i")))
(define-key global-map "\C-cnn" ;new note
(lambda () (interactive) (org-capture nil "n")))
;; allow comment region in the code edit buffer (according to language)
(defun my-org-comment-dwim (&optional arg)
(interactive "P")
(or (org-babel-do-key-sequence-in-edit-buffer (kbd "M-;"))
(comment-dwim arg)))
(define-key org-mode-map
(kbd "M-;") 'my-org-comment-dwim)
(setq org-use-speed-commands t)
;; volatile highlights - temporarily highlight changes from pasting etc
(use-package volatile-highlights
:config
(volatile-highlights-mode t))
(setq org-enforce-todo-dependencies t)
;; Set to 'invisible and blocked tasks wont show up in agenda, t and they will be dimmed
(setq org-agenda-dim-blocked-tasks 'invisible)
;; Don't keep track of completed repeating tasks
(setq org-log-repeat nil)
;; Enable highlight line only for org-agenda-mode (it is annoying in other modes)
(add-hook 'org-agenda-mode-hook 'hl-line-mode)
;; Make agenda full screen without typing 'o'
(add-hook 'org-agenda-finalize-hook (lambda () (delete-other-windows)))
(defun es/skip-unless-work ()
"Skip trees that are not waiting"
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
(if (re-search-forward ":work:" subtree-end t)
nil ; tag found, do not skip
subtree-end))) ; tag not found, continue after end of subtree
;; Block agenda view for agenda and unscheduled tasks
(setq org-agenda-custom-commands
'(("j" "Agenda and unscheduled tasks"
((tags-todo
"-DEADLINE={.+}-SCHEDULED={.+}-dad-mom-beilei-someday-emacs-projects-work")
(agenda ""))
((org-agenda-start-on-weekday nil)
(org-agenda-ndays 2)
(org-deadline-warning-days 0)))
("w" "Work tasks"
((tags-todo
"-DEADLINE={.+}-SCHEDULED={.+}-dad-mom-beilei-someday-emacs-projects")
(agenda ""))
((org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp ":home:"))
(org-agenda-start-on-weekday nil)
(org-agenda-ndays 1)
(org-deadline-warning-days 0)))
("f" "Talking points"
((tags-todo "+beilei")
(tags-todo "+mom")
(tags-todo "+dad"))
((org-agenda-prefix-format "- ")
(org-show-context-detail 'minimal)
(org-agenda-todo-keyword-format "")))
(";" "Someday and projects"
((tags-todo "+someday"))
((org-agenda-prefix-format "- ")
(org-show-context-detail 'minimal)
(org-agenda-remove-tags t)
(org-agenda-todo-keyword-format "")))
("l" "Emacs"
((tags-todo "+emacs"))
((org-agenda-prefix-format "- ")
(org-show-context-detail 'minimal)
(org-agenda-remove-tags t)
(org-agenda-todo-keyword-format "")))
("2" "Mobile tasks"
((tags "-DEADLINE={.+}-SCHEDULED={.+}/+TODO")
(agenda ""))
((org-agenda-prefix-format "- ")
(org-agenda-todo-keyword-format "")
(org-agenda-start-on-weekday nil)
(org-agenda-ndays 3)
(org-deadline-warning-days 0))
("~/Dropbox/org_files/taskpaper_files/da_guai.taskpaper"))))
(setq org-agenda-files '("~/Dropbox/org_files/da_guai.org"))
;; Only ask for confirmation of kills within agenda
;; only if TODO spans more than 2 lines
(setq org-agenda-confirm-kill 2)
(setq org-deadline-warning-days 3)
(setq org-capture-templates
'(("i" "New TODO to Uncategorized TODOs" entry (file+headline
"~/Dropbox/org_files/da_guai.org" "Uncategorized TODOs")
"* TODO %?" :kill-buffer t)
("n" "New note to xnotes.org" entry (file
"~/Dropbox/org_files/xnotes.org")
"* %T\n\n%i%?" :prepend t :empty-lines 1)
("w" "New work note" entry (file
"~/Dropbox/org_files/worknotes.org")
"* %T\n\n%i%?" :kill-buffer t :prepend t :empty-lines 1)
("d" "New daydayup entry" entry (file
"~/Dropbox/org_files/daydayup.org")
"* %T\n\n%?" :kill-buffer t :prepend t :empty-lines 1)))
(use-package org-bullets
:init
(setq org-bullets-bullet-list
'("◉" "◎" "⚫" "○" "►" "◇"))
:config
(setcdr org-bullets-bullet-map nil)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
)
(setq org-src-fontify-natively t
org-src-window-setup 'current-window
org-src-strip-leading-and-trailing-blank-lines t
org-src-preserve-indentation t
org-src-tab-acts-natively t)
(use-package org-journal
:ensure t
:defer t
:bind ("C-c j" . org-journal-new-entry)
:custom
(org-journal-dir "~/Dropbox/journal")
(org-journal-file-type (quote yearly))
)
(use-package org-pomodoro)
(require 'org-pomodoro)
;; Set these here instead of in customize.
(setq org-pomodoro-finished-sound "/Users/apayne/Downloads/Store_Door_Chime.wav")
(setq org-pomodoro-length 25)
(setq org-pomodoro-long-break-sound " /Users/apayne/Downloads/Store_Door_Chime.wav")
(setq org-pomodoro-short-break-sound " /Users/apayne/Downloads/Store_Door_Chime.wav")
(setq org-pomodoro-start-sound " /Users/apayne/Downloads/Store_Door_Chime.wav")
(use-package markdown-mode
:defer t
)
(use-package vmd-mode)
I need to include other stuff in path for emacs https://www.emacswiki.org/emacs/ExecPath
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
(add-to-list 'load-path "/Users/apayne/.emacs.d/elpa/ace-jump-mode-20140616.815/")
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
;you can select the key you prefer to
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
;enable a more powerful jump back function from ace jump mode
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
;; Rahul Org-mode Screenshot takes a screenshot with scrot -s (waits for screen
;; selection), saves it as orgfileopened.org_YYYYMMDD_hhmmss.png, inserts
;; the link and turns on the display-inline-images, showing your screenshot directly
;; to the org-file"
(add-hook 'org-mode-hook
(lambda ()
(defun ros ()
(interactive)
(let ((filename
(concat "./"
(file-name-nondirectory buffer-file-name)
"_"
(format-time-string "%Y%m%d_%H%M%S")
".png")))
(if (executable-find "scrot")
(call-process "scrot" nil nil nil "-s" filename)
(call-process "screencapture" nil nil nil "-s" filename))
(when (file-exists-p filename)
(insert (concat "[[" filename "]]")))
(org-display-inline-images t t)))))