[literate] move Org and Markdown to markup section; move cp-nav to init.org
This commit is contained in:
parent
bfbb95eaa2
commit
2f3992fdc1
|
@ -1,148 +0,0 @@
|
|||
(require 'cp)
|
||||
|
||||
;;;; Navigation improvements
|
||||
|
||||
(add-to-list 'load-path "~/.emacs.d/elisp-git/window-numbering/")
|
||||
|
||||
;; Vim-style prompt-less tag jumping
|
||||
;; http://stackoverflow.com/questions/12074897/automatically-jump-to-tag-in-emacs
|
||||
(global-unset-key (kbd "M-t"))
|
||||
(defun find-tag-no-prompt-other-window ()
|
||||
"Jump to the tag at point in the other window without prompting."
|
||||
(interactive)
|
||||
(find-tag-other-window (find-tag-default)))
|
||||
(defun find-tag-no-prompt ()
|
||||
"Jump to the tag at point without prompting."
|
||||
(interactive)
|
||||
(find-tag (find-tag-default)))
|
||||
|
||||
(cp-set-keys
|
||||
:bindings
|
||||
`((,(kbd "M-t M-t") find-tag-no-prompt-other-window)
|
||||
(,(kbd "M-t M-g") find-tag-no-prompt)
|
||||
(,(kbd "M-t M-p") pop-tag-mark)
|
||||
(,(kbd "M-t M-f") find-tag)
|
||||
(,(kbd "M-t M-s") tags-search)
|
||||
(,(kbd "M-t M-c") tags-loop-continue)))
|
||||
|
||||
;; (require 'view)
|
||||
;; (cp-set-keys
|
||||
;; :bindings
|
||||
;; `((,(kbd "C-v") View-scroll-half-page-forward)
|
||||
;; (,(kbd "M-v") View-scroll-half-page-backward)))
|
||||
;; ;; (cp-set-keys
|
||||
;; ;; :bindings
|
||||
;; ;; `((,(kbd "C-v") scroll-up)
|
||||
;; ;; (,(kbd "M-v") scroll-down)))
|
||||
|
||||
;;;; Need to make maps for
|
||||
;;;; mark-* commands (-sexp, -page, -word, etc)
|
||||
;;;; mark ring
|
||||
|
||||
;;;; Other custom keys
|
||||
(cp-set-keys
|
||||
:bindings
|
||||
`((,(kbd "C-x C-1") delete-other-windows)
|
||||
(,(kbd "C-x C-2") split-window-below)
|
||||
(,(kbd "C-x C-3") split-window-right)
|
||||
(,(kbd "C-x C-0") delete-window)
|
||||
(,(kbd "C-x C-4 C-f") find-file-other-window)
|
||||
;; (,(kbd "C-`") point-to-register)
|
||||
;; (,(kbd "C-'") jump-to-register)
|
||||
(,(kbd "C-x C-d") dired-jump)
|
||||
;; I usually keep Super for the window manager and global hotkeys...
|
||||
(,(kbd "s-i") imenu)
|
||||
;; keypad
|
||||
|
||||
;; set this to run whatever command is bound to C-c C-c, or maybe just C-c
|
||||
;; see (info "(elisp)Translation Keymaps")
|
||||
))
|
||||
|
||||
(with-eval-after-load 'dired
|
||||
(define-key dired-mode-map (kbd "b") 'dired-up-directory)
|
||||
;; (add-hook 'dired-mode-hook 'visual-line-mode)
|
||||
;(global-set-key (kbd "C-,") 'string-rectangle 'TAB)
|
||||
)
|
||||
(global-unset-key (kbd "C-x d"))
|
||||
|
||||
;; (require 'dired-toggle-sudo)
|
||||
;; (define-key dired-mode-map (kbd "C-c C-s") 'dired-toggle-sudo)
|
||||
;; (eval-after-load 'tramp
|
||||
;; '(progn
|
||||
;; ;; Allow to use: /sudo:user@host:/path/to/file
|
||||
;; (add-to-list 'tramp-default-proxies-alist
|
||||
;; '(".*" "\\`.+\\'" "/ssh:%h:"))))
|
||||
(global-set-key (kbd "C-x df") 'delete-frame)
|
||||
;;;; make-frame key is after Helm's config
|
||||
|
||||
;(setq compilation-read-command nil)
|
||||
(defun cp-open-init ()
|
||||
"Open the init.el file."
|
||||
(interactive)
|
||||
(find-file "~/.emacs.d/init.el"))
|
||||
;; todo - store current file name → kill the buffer →
|
||||
;; find-file-literally with the stored filename. also, find out if you
|
||||
;; can open it without modes but with the proper encoding.
|
||||
(defun cp-fcf-literally ()
|
||||
"Find the current file literally. Like find-file-literally but
|
||||
does not prompt for a file name."
|
||||
(interactive)
|
||||
(find-file-literally (buffer-file-name)))
|
||||
(defun cp-kill-buffer ()
|
||||
"Kill the current buffer without prompting."
|
||||
(interactive)
|
||||
(kill-buffer nil))
|
||||
|
||||
(autoload 'ibuffer "ibuffer" "ibuffer" t)
|
||||
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
||||
(with-eval-after-load 'ibuffer
|
||||
(cp-set-keys
|
||||
:unset t
|
||||
:keymap ibuffer-mode-map
|
||||
:bindings
|
||||
`((,(kbd "m"))
|
||||
(,(kbd "U"))))
|
||||
(cp-set-keys
|
||||
:keymap ibuffer-mode-map
|
||||
:bindings
|
||||
`((,(kbd "m f") ibuffer-mark-by-file-name-regexp)
|
||||
(,(kbd "m m") ibuffer-mark-by-mode-regexp)
|
||||
(,(kbd "m n") ibuffer-mark-by-name-regexp)
|
||||
(,(kbd "M") ibuffer-mark-forward)
|
||||
(,(kbd "r") ibuffer-do-replace-regexp)
|
||||
(,(kbd "U") ibuffer-unmark-all)))
|
||||
(add-hook 'ibuffer-mode-hook 'ibuffer-set-filter-groups-by-mode))
|
||||
|
||||
;; (require 'win-switch)
|
||||
;; (global-set-key "\C-xo" 'win-switch-dispatch)
|
||||
;; (win-switch-setup-keys-ijkl)
|
||||
;; (setq win-switch-idle-time 0.5)
|
||||
;; (setq win-switch-other-window-first nil)
|
||||
;; ;(setq win-switch-other-window-first nil)
|
||||
|
||||
(require 'window-numbering)
|
||||
(window-numbering-mode 1)
|
||||
|
||||
(defun cp-maximize-window ()
|
||||
"Run maximize-window if more than one window is present."
|
||||
(interactive)
|
||||
(if (> (length (window-list)) 1)
|
||||
(maximize-window)))
|
||||
|
||||
(defun cp-minimize-window ()
|
||||
"Run minimize-window if more than one window is present."
|
||||
(interactive)
|
||||
(if (> (length (window-list)) 1)
|
||||
(minimize-window)))
|
||||
|
||||
(with-eval-after-load 'doc-view
|
||||
(define-key doc-view-mode-map (kbd "=") 'doc-view-fit-height-to-window))
|
||||
|
||||
(use-package view-mode
|
||||
:bind
|
||||
(:map view-mode-map
|
||||
("x" . nil)
|
||||
("<backspace>" . scroll-down-command)
|
||||
("SPC" . scroll-up-command)))
|
||||
|
||||
(provide 'cp-nav)
|
747
init.org
747
init.org
|
@ -959,7 +959,6 @@ Ask for confirmation before saving cookies. I'd rather just disallow them all th
|
|||
(require 'cp-lily)
|
||||
(require 'cp-sfz)
|
||||
(require 'cp-lisp)
|
||||
(require 'cp-nav)
|
||||
|
||||
;; (ispell-change-dictionary "en")
|
||||
(setq ispell-dictionary "en")
|
||||
|
@ -1899,305 +1898,151 @@ Don't try to check if there are files with a certain extension...it will lead to
|
|||
(beginning-of-line)
|
||||
(recenter)))
|
||||
#+END_SRC
|
||||
** Org
|
||||
|
||||
** Navigation
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package org
|
||||
:commands (org-drag-line-backward org-drag-line-forward)
|
||||
:bind (("C-c C-h" . nil)
|
||||
:map org-mode-map
|
||||
("C-c C-c" . org-previous-visible-heading)
|
||||
("C-c C-r" . org-next-visible-heading)
|
||||
("C-c C-s" . org-forward-heading-same-level)
|
||||
;; does not work...
|
||||
("C-c C-h" . org-backward-heading-same-level))
|
||||
:config
|
||||
(general-def "<f5> o" 'org-mode)
|
||||
(general-def org-mode-map
|
||||
"C-," 'nil
|
||||
"M-r" 'org-metadown
|
||||
"M-c" 'org-metaup
|
||||
"C-c C--" 'org-ctrl-c-minus
|
||||
"C-c C-," 'org-metaleft
|
||||
"C-c C-." 'org-metaright
|
||||
;; "C-j" 'org-return
|
||||
;; "C-m" 'org-return-indent
|
||||
"C-c C-9" 'org-mark-ring-goto
|
||||
"C-c C-/" 'org-sparse-tree
|
||||
"M-w" 'cp-copy-line-or-link
|
||||
"C-c C-]" 'cp-org-set-tags
|
||||
"C-M-x" 'cp/eval-sexp
|
||||
"C-c C-o" 'cp/org-open
|
||||
;; boon
|
||||
"C-c C--" 'org-ctrl-c-minus
|
||||
"C-c ]" 'cp-org-set-tags
|
||||
"C-c ," 'org-metaleft
|
||||
"C-c ." 'org-metaright
|
||||
"M-h" 'default-indent-new-line)
|
||||
(mapc (lambda (pair)
|
||||
(add-to-list 'org-file-apps pair))
|
||||
'(("txt" . emacs)
|
||||
("org" . emacs)
|
||||
;; ("pdf" . zathura)
|
||||
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
|
||||
;; (t . "xdg-open %s")
|
||||
(add-to-list 'load-path "~/.emacs.d/elisp-git/window-numbering/")
|
||||
|
||||
("pdf" . system)
|
||||
;; ("pdf" . "zathura %s")
|
||||
;; (auto-mode . emacs)
|
||||
;; (system . "xdg-open %s")
|
||||
(system . "zathura %s")
|
||||
;; (t . system)
|
||||
))
|
||||
(setq org-todo-keywords '((sequence "TODO" "RESEARCH" "STARTED" "DONE"))
|
||||
org-image-actual-width 400
|
||||
org-cycle-include-plain-lists 'integrate
|
||||
org-link-search-must-match-exact-headline nil
|
||||
|
||||
org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"contrapunctus/org-html.css\" />"
|
||||
|
||||
org-export-default-inline-image-rule
|
||||
`(("https" .
|
||||
,(format "\\.%s\\'"
|
||||
(regexp-opt
|
||||
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
|
||||
"xpm" "pbm" "pgm" "ppm" "webp") t)))
|
||||
("file" .
|
||||
,(format "\\.%s\\'"
|
||||
(regexp-opt
|
||||
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
|
||||
"xpm" "pbm" "pgm" "ppm" "webp") t)))))
|
||||
;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html
|
||||
(defun org-link-gemini-export-link (link desc format)
|
||||
"Create export version of LINK and DESC to FORMAT."
|
||||
(let ((link (concat "gemini://" link)))
|
||||
(cond
|
||||
((eq format 'html)
|
||||
(format "<a href=\"%s\">%s</a>" link desc))
|
||||
((eq format 'latex)
|
||||
(format "\\href{%s}{%s}" link desc))
|
||||
(t ;; `ascii', `md', `hugo', etc.
|
||||
(format "[%s](%s)" desc link)))))
|
||||
(org-link-set-parameters "gemini" :export #'org-link-gemini-export-link)
|
||||
(add-hook 'org-insert-heading-hook #'contrapunctus-org-insert-timestamp))
|
||||
|
||||
(defun cp-org-insert-block (type &optional lang)
|
||||
"Insert block of TYPE at point, or at beginning and end of region.
|
||||
TYPE should be an Org block type, e.g. SRC, QUOTE, etc.
|
||||
|
||||
If TYPE is SRC, LANG should be the name of the language as a string, e.g. \"emacs-lisp\"."
|
||||
(let* ((column (- (point) (point-at-bol)))
|
||||
(indent (make-string column ?\ ))
|
||||
(region-start (region-beginning))
|
||||
(region-end (region-end))
|
||||
(start-string (format "#+BEGIN_%s %s\n" type
|
||||
(if (stringp lang) lang "")))
|
||||
(end-string (format "%s#+END_%s" indent type)))
|
||||
;; create a block around a region - preserve position of point
|
||||
(cond ((region-active-p)
|
||||
(save-excursion
|
||||
;; inserting at region-start would make region-end
|
||||
;; invalid, so we insert at the end first
|
||||
(goto-char region-end)
|
||||
(insert end-string "\n")
|
||||
(goto-char region-start)
|
||||
(insert start-string)))
|
||||
;; new empty block - insert the block syntax and place point
|
||||
;; inside the block
|
||||
(t (insert start-string)
|
||||
(let ((point-inside-block (point)))
|
||||
(insert "\n" end-string)
|
||||
(goto-char point-inside-block)
|
||||
(insert indent))))))
|
||||
|
||||
;; (use-package org-src-mode
|
||||
;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode)))))
|
||||
|
||||
;; (defun cp-org-expand-all ()
|
||||
;; (interactive)
|
||||
;; ;; todo - define inner recursive function
|
||||
;; (beginning-of-buffer)
|
||||
;; ;; todo - check if we are on a heading
|
||||
;; (org-forward-heading-same-level)
|
||||
;; ())
|
||||
|
||||
;; I dislike having to navigate within a line to reach a link - with
|
||||
;; this command I just need to be on the same line as the link.
|
||||
(defun cp/org-open (&optional arg reference-buffer)
|
||||
(interactive "P")
|
||||
(beginning-of-visual-line)
|
||||
(unless (looking-at-p (rx-to-string '(or "http" "[")))
|
||||
(org-next-link))
|
||||
(org-open-at-point))
|
||||
|
||||
(defun cp-copy-line-or-link (prefix-arg)
|
||||
"Copy address of org-mode link after point, ignoring whitespace,
|
||||
link description (if any) and org-mode header and list syntax. If
|
||||
not before a link, or with a prefix arg, call
|
||||
`whole-line-or-region-kill-ring-save' instead.
|
||||
|
||||
BUG - improper behaviour with checkboxes.
|
||||
2018-03-17T21:15:17+0530 - hopefully fixed now."
|
||||
(interactive "P")
|
||||
(let ((point-a (point)))
|
||||
(cl-flet ((copy-to-closing-bracket
|
||||
()
|
||||
(let ((point-b (point)))
|
||||
(re-search-forward "\\]")
|
||||
(copy-region-as-kill point-b
|
||||
(- (point) 1)))))
|
||||
|
||||
(if (save-excursion
|
||||
(or (use-region-p)
|
||||
prefix-arg
|
||||
(cp/re-search-line "\\[[-X ]\\]")))
|
||||
(whole-line-or-region-kill-ring-save prefix-arg)
|
||||
|
||||
(cond ( ;; (cp/org-link-ahead-p)
|
||||
(cp/re-search-line "\\[")
|
||||
;; (if (looking-at "\\[")
|
||||
;; (forward-char))
|
||||
(forward-char)
|
||||
(copy-to-closing-bracket)
|
||||
(goto-char point-a))
|
||||
|
||||
( ;; (cp/org-link-ahead-p 'implicit)
|
||||
(cp/re-search-line "http")
|
||||
(backward-word)
|
||||
(let ((point-b (point)))
|
||||
(re-search-forward (rx (or eol (and printing " "))))
|
||||
(copy-region-as-kill point-b
|
||||
(point)))
|
||||
(goto-char point-a))
|
||||
|
||||
;; TODO - org-previous-link will land you at the start
|
||||
;; of the DESCRIPTION of the previous link, if it has
|
||||
;; one, but to the user it will look like they are at
|
||||
;; the start of the link. Add a case to handle this.
|
||||
|
||||
;; Does not work if there is an org TODO marker in a
|
||||
;; header.
|
||||
|
||||
(t (whole-line-or-region-kill-ring-save prefix-arg)))))))
|
||||
|
||||
(defun cp/org-table-convert-tsv ()
|
||||
;; Vim-style prompt-less tag jumping
|
||||
;; http://stackoverflow.com/questions/12074897/automatically-jump-to-tag-in-emacs
|
||||
(global-unset-key (kbd "M-t"))
|
||||
(defun find-tag-no-prompt-other-window ()
|
||||
"Jump to the tag at point in the other window without prompting."
|
||||
(interactive)
|
||||
(with-output-to-temp-buffer "cp/org-table-convert-tsv"
|
||||
(->> (buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(replace-regexp-in-string "^| *" "")
|
||||
(replace-regexp-in-string " *| *" " ")
|
||||
(replace-regexp-in-string "^-.*$" "")))
|
||||
(with-current-buffer "cp/org-table-convert-tsv"
|
||||
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||
(write-file (read-from-minibuffer "Output filename: "))))
|
||||
|
||||
(defun cp-org-set-tags ()
|
||||
(find-tag-other-window (find-tag-default)))
|
||||
(defun find-tag-no-prompt ()
|
||||
"Jump to the tag at point without prompting."
|
||||
(interactive)
|
||||
(let ((all-tags (org-get-buffer-tags))
|
||||
(current-tags (org-get-tags)))
|
||||
(save-excursion
|
||||
(org-back-to-heading)
|
||||
(org-set-tags
|
||||
(completing-read-multiple
|
||||
"Tag: " all-tags nil 'confirm
|
||||
(mapconcat #'identity current-tags ",")
|
||||
'org-tags-history)))))
|
||||
(find-tag (find-tag-default)))
|
||||
|
||||
(defun contrapunctus-org-insert-timestamp ()
|
||||
(save-excursion
|
||||
(insert "\n" "<" (format-time-string "%FT%T%z") ">")))
|
||||
(cp-set-keys
|
||||
:bindings
|
||||
`((,(kbd "M-t M-t") find-tag-no-prompt-other-window)
|
||||
(,(kbd "M-t M-g") find-tag-no-prompt)
|
||||
(,(kbd "M-t M-p") pop-tag-mark)
|
||||
(,(kbd "M-t M-f") find-tag)
|
||||
(,(kbd "M-t M-s") tags-search)
|
||||
(,(kbd "M-t M-c") tags-loop-continue)))
|
||||
|
||||
(use-package org-indent
|
||||
:hook (org-mode . org-indent-mode))
|
||||
;; (require 'view)
|
||||
;; (cp-set-keys
|
||||
;; :bindings
|
||||
;; `((,(kbd "C-v") View-scroll-half-page-forward)
|
||||
;; (,(kbd "M-v") View-scroll-half-page-backward)))
|
||||
;; ;; (cp-set-keys
|
||||
;; ;; :bindings
|
||||
;; ;; `((,(kbd "C-v") scroll-up)
|
||||
;; ;; (,(kbd "M-v") scroll-down)))
|
||||
|
||||
(use-package ox-texinfo)
|
||||
#+END_SRC
|
||||
** markdown-mode :editing:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package markdown-mode
|
||||
:mode "\\.md\\'"
|
||||
:hook
|
||||
(markdown-mode . (lambda ()
|
||||
(make-local-variable 'before-save-hook)
|
||||
(add-hook 'before-save-hook 'markdown-cleanup-list-numbers)))
|
||||
(markdown-mode . markdown-display-inline-images)
|
||||
:config (setq markdown-command "cmark"
|
||||
markdown-css-paths '("style.css")
|
||||
markdown-display-remote-images t
|
||||
markdown-max-image-size '(500 . 500)
|
||||
;; reflows text to suit different screens
|
||||
markdown-xhtml-header-content
|
||||
(concat "<meta name=\"viewport\" "
|
||||
"content=\"width=device-width, "
|
||||
"initial-scale=1.0, "
|
||||
"user-scalable=yes\" />"))
|
||||
(when (featurep 'boon)
|
||||
(general-def markdown-mode-map
|
||||
"C-c ," 'markdown-promote
|
||||
"C-c ." 'markdown-demote
|
||||
"C-c C-e" 'markdown-export))
|
||||
(setq-default ;; markdown-hide-markup t ;; has a bug with heading cycling
|
||||
markdown-hide-urls t)
|
||||
;;;; Need to make maps for
|
||||
;;;; mark-* commands (-sexp, -page, -word, etc)
|
||||
;;;; mark ring
|
||||
|
||||
;;;; Other custom keys
|
||||
(cp-set-keys
|
||||
:bindings
|
||||
`((,(kbd "C-x C-1") delete-other-windows)
|
||||
(,(kbd "C-x C-2") split-window-below)
|
||||
(,(kbd "C-x C-3") split-window-right)
|
||||
(,(kbd "C-x C-0") delete-window)
|
||||
(,(kbd "C-x C-4 C-f") find-file-other-window)
|
||||
;; (,(kbd "C-`") point-to-register)
|
||||
;; (,(kbd "C-'") jump-to-register)
|
||||
(,(kbd "C-x C-d") dired-jump)
|
||||
;; I usually keep Super for the window manager and global hotkeys...
|
||||
(,(kbd "s-i") imenu)
|
||||
;; keypad
|
||||
|
||||
;; set this to run whatever command is bound to C-c C-c, or maybe just C-c
|
||||
;; see (info "(elisp)Translation Keymaps")
|
||||
))
|
||||
|
||||
(with-eval-after-load 'dired
|
||||
(define-key dired-mode-map (kbd "b") 'dired-up-directory)
|
||||
;; (add-hook 'dired-mode-hook 'visual-line-mode)
|
||||
;(global-set-key (kbd "C-,") 'string-rectangle 'TAB)
|
||||
)
|
||||
(global-unset-key (kbd "C-x d"))
|
||||
|
||||
;; (require 'dired-toggle-sudo)
|
||||
;; (define-key dired-mode-map (kbd "C-c C-s") 'dired-toggle-sudo)
|
||||
;; (eval-after-load 'tramp
|
||||
;; '(progn
|
||||
;; ;; Allow to use: /sudo:user@host:/path/to/file
|
||||
;; (add-to-list 'tramp-default-proxies-alist
|
||||
;; '(".*" "\\`.+\\'" "/ssh:%h:"))))
|
||||
(global-set-key (kbd "C-x df") 'delete-frame)
|
||||
;;;; make-frame key is after Helm's config
|
||||
|
||||
;(setq compilation-read-command nil)
|
||||
(defun cp-open-init ()
|
||||
"Open the init.el file."
|
||||
(interactive)
|
||||
(find-file "~/.emacs.d/init.el"))
|
||||
;; todo - store current file name → kill the buffer →
|
||||
;; find-file-literally with the stored filename. also, find out if you
|
||||
;; can open it without modes but with the proper encoding.
|
||||
(defun cp-fcf-literally ()
|
||||
"Find the current file literally. Like find-file-literally but
|
||||
does not prompt for a file name."
|
||||
(interactive)
|
||||
(find-file-literally (buffer-file-name)))
|
||||
(defun cp-kill-buffer ()
|
||||
"Kill the current buffer without prompting."
|
||||
(interactive)
|
||||
(kill-buffer nil))
|
||||
|
||||
(autoload 'ibuffer "ibuffer" "ibuffer" t)
|
||||
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
||||
(with-eval-after-load 'ibuffer
|
||||
(cp-set-keys
|
||||
:unset t
|
||||
:keymap ibuffer-mode-map
|
||||
:bindings
|
||||
`((,(kbd "m"))
|
||||
(,(kbd "U"))))
|
||||
(cp-set-keys
|
||||
:keymap ibuffer-mode-map
|
||||
:bindings
|
||||
`((,(kbd "m f") ibuffer-mark-by-file-name-regexp)
|
||||
(,(kbd "m m") ibuffer-mark-by-mode-regexp)
|
||||
(,(kbd "m n") ibuffer-mark-by-name-regexp)
|
||||
(,(kbd "M") ibuffer-mark-forward)
|
||||
(,(kbd "r") ibuffer-do-replace-regexp)
|
||||
(,(kbd "U") ibuffer-unmark-all)))
|
||||
(add-hook 'ibuffer-mode-hook 'ibuffer-set-filter-groups-by-mode))
|
||||
|
||||
;; (require 'win-switch)
|
||||
;; (global-set-key "\C-xo" 'win-switch-dispatch)
|
||||
;; (win-switch-setup-keys-ijkl)
|
||||
;; (setq win-switch-idle-time 0.5)
|
||||
;; (setq win-switch-other-window-first nil)
|
||||
;; ;(setq win-switch-other-window-first nil)
|
||||
|
||||
(require 'window-numbering)
|
||||
(window-numbering-mode 1)
|
||||
|
||||
(defun cp-maximize-window ()
|
||||
"Run maximize-window if more than one window is present."
|
||||
(interactive)
|
||||
(if (> (length (window-list)) 1)
|
||||
(maximize-window)))
|
||||
|
||||
(defun cp-minimize-window ()
|
||||
"Run minimize-window if more than one window is present."
|
||||
(interactive)
|
||||
(if (> (length (window-list)) 1)
|
||||
(minimize-window)))
|
||||
|
||||
(with-eval-after-load 'doc-view
|
||||
(define-key doc-view-mode-map (kbd "=") 'doc-view-fit-height-to-window))
|
||||
|
||||
(use-package view-mode
|
||||
:bind
|
||||
(:map markdown-mode-map
|
||||
;; ("M-n" . org-drag-element-forward)
|
||||
;; ("M-p" . org-drag-element-backward)
|
||||
;; ("C-c C-o" . markdown-follow-link-at-point)
|
||||
("M-r" . markdown-move-down)
|
||||
("M-c" . markdown-move-up)
|
||||
("C-c C--" . org-cycle-list-bullet)
|
||||
([mouse-1] . markdown-cycle)
|
||||
("C-c C-x C-n" . markdown-next-link)
|
||||
("C-c C-x C-p" . markdown-previous-link)
|
||||
|
||||
("C-c C-h C-u" . #'markdown-toggle-url-hiding)
|
||||
("C-c C-h C-m" . #'markdown-toggle-markup-hiding)
|
||||
("C-c C-h C-i" . #'markdown-toggle-inline-images)
|
||||
("C-c C-r" . #'reverse-region)))
|
||||
|
||||
(defun cp/copy-line-or-md-link (prefix-arg)
|
||||
(interactive "P")
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at-p ".*http")
|
||||
(progn
|
||||
(cp/re-search-line "http")
|
||||
(forward-char -4)
|
||||
(kill-new (thing-at-point 'url))))))
|
||||
#+END_SRC
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq truncate-partial-width-windows nil
|
||||
truncate-lines t)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'erc-mode-hook 'visual-line-mode)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'comint-mode-hook 'visual-line-mode)
|
||||
|
||||
;; commented out on 2018-03-19T14:18:34+0530
|
||||
;; (add-hook 'markdown-mode-hook 'auto-fill-mode)
|
||||
;; (add-hook 'text-mode-hook 'auto-fill-mode)
|
||||
|
||||
;; (add-hook 'paredit-mode-hook 'auto-fill-mode)
|
||||
|
||||
;;;; Tab settings
|
||||
;; (setq default-tab-width 4)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq tab-width 4)
|
||||
;(define-key text-mode-map (kbd "TAB") 'self-insert-command)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq-default indent-tabs-mode nil)
|
||||
(:map view-mode-map
|
||||
("x" . nil)
|
||||
("<backspace>" . scroll-down-command)
|
||||
("SPC" . scroll-up-command)))
|
||||
#+END_SRC
|
||||
|
||||
** scrolling
|
||||
|
@ -2520,6 +2365,324 @@ SLIME opens CLHS links in Firefox, but I'd rather open them in Tor Browser; Tor
|
|||
("M-r" . git-commit-next-message)))
|
||||
#+END_SRC
|
||||
** markup
|
||||
*** Org
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package org
|
||||
:load-path "~/.emacs.d/elisp-git/org-mode"
|
||||
:hook (org-mode . contrapunctus-disable-nameless-key)
|
||||
:commands (org-drag-line-backward org-drag-line-forward)
|
||||
:bind (("C-c C-h" . nil)
|
||||
:map org-mode-map
|
||||
("C-c C-c" . org-previous-visible-heading)
|
||||
("C-c C-r" . org-next-visible-heading)
|
||||
("C-c C-s" . org-forward-heading-same-level)
|
||||
;; does not work...
|
||||
("C-c C-h" . org-backward-heading-same-level)
|
||||
("C-c C-j" . org-ctrl-c-ctrl-c)) ;; "c c" in boon/dvorak
|
||||
:config
|
||||
(general-def "<f5> o" 'org-mode)
|
||||
(general-def org-mode-map
|
||||
"C-," 'nil
|
||||
"M-r" 'org-metadown
|
||||
"M-c" 'org-metaup
|
||||
"C-c C--" 'org-ctrl-c-minus
|
||||
"C-c C-," 'org-metaleft
|
||||
"C-c C-." 'org-metaright
|
||||
;; "C-j" 'org-return
|
||||
;; "C-m" 'org-return-indent
|
||||
"C-c C-9" 'org-mark-ring-goto
|
||||
"C-c C-/" 'org-sparse-tree
|
||||
"M-w" 'cp-copy-line-or-link
|
||||
"C-c C-]" 'cp-org-set-tags
|
||||
"C-M-x" 'cp/eval-sexp
|
||||
"C-c C-o" 'cp/org-open
|
||||
;; boon
|
||||
"C-c C--" 'org-ctrl-c-minus
|
||||
"C-c ]" 'cp-org-set-tags
|
||||
"C-c ," 'org-metaleft
|
||||
"C-c ." 'org-metaright
|
||||
"M-h" 'default-indent-new-line)
|
||||
(mapc (lambda (pair)
|
||||
(add-to-list 'org-file-apps pair))
|
||||
'(("txt" . emacs)
|
||||
("org" . emacs)
|
||||
;; ("pdf" . zathura)
|
||||
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
|
||||
;; (t . "xdg-open %s")
|
||||
|
||||
("pdf" . system)
|
||||
;; ("pdf" . "zathura %s")
|
||||
;; (auto-mode . emacs)
|
||||
;; (system . "xdg-open %s")
|
||||
(system . "zathura %s")
|
||||
;; (t . system)
|
||||
))
|
||||
(setq org-todo-keywords '((sequence "TODO" "RESEARCH" "STARTED" "DONE"))
|
||||
org-image-actual-width 400
|
||||
org-cycle-include-plain-lists 'integrate
|
||||
org-link-search-must-match-exact-headline nil
|
||||
|
||||
org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />"
|
||||
org-html-self-link-headlines t
|
||||
|
||||
org-export-default-inline-image-rule
|
||||
`(("https" .
|
||||
,(format "\\.%s\\'"
|
||||
(regexp-opt
|
||||
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
|
||||
"xpm" "pbm" "pgm" "ppm" "webp") t)))
|
||||
("file" .
|
||||
,(format "\\.%s\\'"
|
||||
(regexp-opt
|
||||
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
|
||||
"xpm" "pbm" "pgm" "ppm" "webp") t)))))
|
||||
;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html
|
||||
(defun org-link-gemini-export-link (link desc format)
|
||||
"Create export version of LINK and DESC to FORMAT."
|
||||
(let ((link (concat "gemini:" link)))
|
||||
(cond
|
||||
((eq format 'html)
|
||||
(format "<a href=\"%s\">%s</a>" link desc))
|
||||
((eq format 'latex)
|
||||
;; (format "\\href{%s}{%s}" link desc)
|
||||
(format "\\url{%s}" link))
|
||||
(t ;; `ascii', `md', `hugo', etc.
|
||||
(format "[%s](%s)" desc link)))))
|
||||
(org-link-set-parameters "gemini" :export #'org-link-gemini-export-link)
|
||||
(add-hook 'org-insert-heading-hook #'contrapunctus-org-insert-timestamp)
|
||||
|
||||
(defun contrapunctus-disable-nameless-key ()
|
||||
(define-key nameless-mode-map (kbd "C-c C--") nil)))
|
||||
|
||||
(defun cp-org-insert-block (type &optional lang)
|
||||
"Insert block of TYPE at point, or at beginning and end of region.
|
||||
TYPE should be an Org block type, e.g. SRC, QUOTE, etc.
|
||||
|
||||
If TYPE is SRC, LANG should be the name of the language as a string, e.g. \"emacs-lisp\"."
|
||||
(let* ((column (- (point) (point-at-bol)))
|
||||
(indent (make-string column ?\ ))
|
||||
(region-start (region-beginning))
|
||||
(region-end (region-end))
|
||||
(start-string (format "#+BEGIN_%s %s\n" type
|
||||
(if (stringp lang) lang "")))
|
||||
(end-string (format "%s#+END_%s" indent type)))
|
||||
;; create a block around a region - preserve position of point
|
||||
(cond ((region-active-p)
|
||||
(save-excursion
|
||||
;; inserting at region-start would make region-end
|
||||
;; invalid, so we insert at the end first
|
||||
(goto-char region-end)
|
||||
(insert end-string "\n")
|
||||
(goto-char region-start)
|
||||
(insert start-string)))
|
||||
;; new empty block - insert the block syntax and place point
|
||||
;; inside the block
|
||||
(t (insert start-string)
|
||||
(let ((point-inside-block (point)))
|
||||
(insert "\n" end-string)
|
||||
(goto-char point-inside-block)
|
||||
(insert indent))))))
|
||||
|
||||
;; (use-package org-src-mode
|
||||
;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode)))))
|
||||
|
||||
;; (defun cp-org-expand-all ()
|
||||
;; (interactive)
|
||||
;; ;; todo - define inner recursive function
|
||||
;; (beginning-of-buffer)
|
||||
;; ;; todo - check if we are on a heading
|
||||
;; (org-forward-heading-same-level)
|
||||
;; ())
|
||||
|
||||
;; I dislike having to navigate within a line to reach a link - with
|
||||
;; this command I just need to be on the same line as the link.
|
||||
(defun cp/org-open (&optional arg reference-buffer)
|
||||
(interactive "P")
|
||||
(beginning-of-visual-line)
|
||||
(unless (looking-at-p (rx-to-string '(or "http" "[")))
|
||||
(org-next-link))
|
||||
(org-open-at-point))
|
||||
|
||||
(defun cp-copy-line-or-link (prefix-arg)
|
||||
"Copy address of org-mode link after point, ignoring whitespace,
|
||||
link description (if any) and org-mode header and list syntax. If
|
||||
not before a link, or with a prefix arg, call
|
||||
`whole-line-or-region-kill-ring-save' instead.
|
||||
|
||||
BUG - improper behaviour with checkboxes.
|
||||
2018-03-17T21:15:17+0530 - hopefully fixed now."
|
||||
(interactive "P")
|
||||
(let ((point-a (point)))
|
||||
(cl-flet ((copy-to-closing-bracket
|
||||
()
|
||||
(let ((point-b (point)))
|
||||
(re-search-forward "\\]")
|
||||
(copy-region-as-kill point-b
|
||||
(- (point) 1)))))
|
||||
|
||||
(if (save-excursion
|
||||
(or (use-region-p)
|
||||
prefix-arg
|
||||
(cp/re-search-line "\\[[-X ]\\]")))
|
||||
(whole-line-or-region-kill-ring-save prefix-arg)
|
||||
|
||||
(cond ( ;; (cp/org-link-ahead-p)
|
||||
(cp/re-search-line "\\[")
|
||||
;; (if (looking-at "\\[")
|
||||
;; (forward-char))
|
||||
(forward-char)
|
||||
(copy-to-closing-bracket)
|
||||
(goto-char point-a))
|
||||
|
||||
( ;; (cp/org-link-ahead-p 'implicit)
|
||||
(cp/re-search-line "http")
|
||||
(backward-word)
|
||||
(let ((point-b (point)))
|
||||
(re-search-forward (rx (or eol (and printing " "))))
|
||||
(copy-region-as-kill point-b
|
||||
(point)))
|
||||
(goto-char point-a))
|
||||
|
||||
;; TODO - org-previous-link will land you at the start
|
||||
;; of the DESCRIPTION of the previous link, if it has
|
||||
;; one, but to the user it will look like they are at
|
||||
;; the start of the link. Add a case to handle this.
|
||||
|
||||
;; Does not work if there is an org TODO marker in a
|
||||
;; header.
|
||||
|
||||
(t (whole-line-or-region-kill-ring-save prefix-arg)))))))
|
||||
|
||||
(defun cp/org-table-convert-tsv ()
|
||||
(interactive)
|
||||
(with-output-to-temp-buffer "cp/org-table-convert-tsv"
|
||||
(->> (buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(replace-regexp-in-string "^| *" "")
|
||||
(replace-regexp-in-string " *| *" " ")
|
||||
(replace-regexp-in-string "^-.*$" "")))
|
||||
(with-current-buffer "cp/org-table-convert-tsv"
|
||||
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||
(write-file (read-from-minibuffer "Output filename: "))))
|
||||
|
||||
(defun cp-org-set-tags ()
|
||||
(interactive)
|
||||
(let ((all-tags (org-get-buffer-tags))
|
||||
(current-tags (org-get-tags)))
|
||||
(save-excursion
|
||||
(org-back-to-heading)
|
||||
(org-set-tags
|
||||
(completing-read-multiple
|
||||
"Tag: " all-tags nil 'confirm
|
||||
(mapconcat #'identity current-tags ",")
|
||||
'org-tags-history)))))
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun contrapunctus-org-insert-timestamp ()
|
||||
(save-excursion
|
||||
(insert "\n" "<" (format-time-string "%FT%T%z") ">")))
|
||||
|
||||
(use-package org-indent
|
||||
:hook (org-mode . org-indent-mode))
|
||||
|
||||
(use-package ox-texinfo)
|
||||
#+END_SRC
|
||||
**** org-html-themify
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package org-html-themify
|
||||
:disabled t
|
||||
:load-path "~/.emacs.d/elisp-git/org-html-themify/"
|
||||
:load-path "~/.emacs.d/elisp-git/hexrgb/"
|
||||
:hook (org-mode . org-html-themify-mode)
|
||||
:config
|
||||
(setq org-html-themify-themes
|
||||
'((dark . doom-molokai))))
|
||||
#+END_SRC
|
||||
*** markdown-mode :editing:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package markdown-mode
|
||||
:mode "\\.md\\'"
|
||||
:hook
|
||||
(markdown-mode . (lambda ()
|
||||
(make-local-variable 'before-save-hook)
|
||||
(add-hook 'before-save-hook 'markdown-cleanup-list-numbers)))
|
||||
(markdown-mode . markdown-display-inline-images)
|
||||
:config (setq markdown-command "cmark"
|
||||
markdown-css-paths '("style.css")
|
||||
markdown-display-remote-images t
|
||||
markdown-max-image-size '(500 . 500)
|
||||
;; reflows text to suit different screens
|
||||
markdown-xhtml-header-content
|
||||
(concat "<meta name=\"viewport\" "
|
||||
"content=\"width=device-width, "
|
||||
"initial-scale=1.0, "
|
||||
"user-scalable=yes\" />"))
|
||||
(when (featurep 'boon)
|
||||
(general-def markdown-mode-map
|
||||
"C-c ," 'markdown-promote
|
||||
"C-c ." 'markdown-demote
|
||||
"C-c C-e" 'markdown-export))
|
||||
(setq-default ;; markdown-hide-markup t ;; has a bug with heading cycling
|
||||
markdown-hide-urls t)
|
||||
:bind
|
||||
(:map markdown-mode-map
|
||||
;; ("M-n" . org-drag-element-forward)
|
||||
;; ("M-p" . org-drag-element-backward)
|
||||
;; ("C-c C-o" . markdown-follow-link-at-point)
|
||||
("M-r" . markdown-move-down)
|
||||
("M-c" . markdown-move-up)
|
||||
("C-c C--" . org-cycle-list-bullet)
|
||||
([mouse-1] . markdown-cycle)
|
||||
("C-c C-x C-n" . markdown-next-link)
|
||||
("C-c C-x C-p" . markdown-previous-link)
|
||||
|
||||
("C-c C-h C-u" . #'markdown-toggle-url-hiding)
|
||||
("C-c C-h C-m" . #'markdown-toggle-markup-hiding)
|
||||
("C-c C-h C-i" . #'markdown-toggle-inline-images)
|
||||
("C-c C-r" . #'reverse-region)))
|
||||
|
||||
(defun cp/copy-line-or-md-link (prefix-arg)
|
||||
(interactive "P")
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at-p ".*http")
|
||||
(progn
|
||||
(cp/re-search-line "http")
|
||||
(forward-char -4)
|
||||
(kill-new (thing-at-point 'url))))))
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'erc-mode-hook 'visual-line-mode)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'comint-mode-hook 'visual-line-mode)
|
||||
|
||||
;; commented out on 2018-03-19T14:18:34+0530
|
||||
;; (add-hook 'markdown-mode-hook 'auto-fill-mode)
|
||||
;; (add-hook 'text-mode-hook 'auto-fill-mode)
|
||||
|
||||
;; (add-hook 'paredit-mode-hook 'auto-fill-mode)
|
||||
|
||||
;;;; Tab settings
|
||||
;; (setq default-tab-width 4)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq tab-width 4)
|
||||
;(define-key text-mode-map (kbd "TAB") 'self-insert-command)
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq-default indent-tabs-mode nil)
|
||||
#+END_SRC
|
||||
|
||||
*** mediawiki-mode
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package mediawiki
|
||||
|
|
Loading…
Reference in New Issue