Skip to content

Commit

Permalink
Ob-ledger, move help keybindings, tweaks in completion/selection
Browse files Browse the repository at this point in the history
  • Loading branch information
icostan committed Apr 7, 2022
1 parent 71d89dc commit 3776ca2
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 57 deletions.
4 changes: 2 additions & 2 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@
(use-package themes :load-path "init")
(use-package ui :load-path "init")
(use-package vim :load-path "init")
(use-package keybindings-general :load-path "init")
;; (use-package completion-company :load-path "init")
(use-package completion-corfu :load-path "init")
(use-package keybindings-general :load-path "init")
;; (use-package selection-helm :load-path "init")
;; (use-package selection-ivy :load-path "init")
(use-package selection-vertico :load-path "init")
(use-package project-management :load-path "init")
(use-package langs :load-path "init")
(use-package misc :load-path "init")
(use-package git :load-path "init")
(use-package editing :load-path "init")
Expand All @@ -145,6 +144,7 @@
(use-package trees :load-path "init")
(use-package windows :load-path "init")
(use-package helper :load-path "init")
(use-package langs :load-path "init")

(message "==> INIT: DONE, %s." (user-login-name))
(message "")
Expand Down
3 changes: 3 additions & 0 deletions init/completion-corfu.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
;;; Code:

(use-package corfu
:after general
:custom
(corfu-cycle t)
(corfu-auto t)
Expand Down Expand Up @@ -61,6 +62,8 @@
(completion-cycle-threshold nil)
(tab-always-indent 'complete))

(message "==> INIT: completion-corfu.el")

(provide 'completion-corfu)

;;; completion-corfu.el ends here
46 changes: 45 additions & 1 deletion init/helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,51 @@

(use-package helpful
:custom
(helpful-max-highlight 10000))
(helpful-max-highlight 10000)
:general
(icostan/leader-keys
:states 'normal
"h" '(nil :wk "help")
"hh" '(helpful-at-point :wk "at point (default)")

"hw" '(nil :wk "which-key")
"hwr" '(which-key-show-top-level :wk "root")
"hwk" '(which-key-show-keymap :wk "keymap")
"hwM" '(which-key-show-full-major-mode :wk "major mode")
"hwm" '(which-key-show-full-minor-mode-keymap :wk "minor mode")

"ha" '(nil :wk "apropos")
"haa" '(apropos :wk "apropos (default)")
"haw" '(apropos-all-words :wk "all")
"hac" '(apropos-command :wk "command")
"haf" '(apropos-function :wk "function")
"hav" '(apropos-variable :wk "variable")

"hd" '(nil :wk "describe")
"hdd" '(helpful-at-point :wk "token at point")
"hdv" '(helpful-variable :wk "variable")
"hdc" '(helpful-command :wk "command")
"hdf" '(helpful-callable :wk "function or macro")
"hdM" '(helpful-macro :wk "macro")
"hdm" '(describe-mode :wk "mode")
"hdk" '(helpful-key :wk "key")
"hdK" '(describe-keymap :wk "keymap")
"hdb" '(describe-bindings :wk "bindings")
"hda" '(describe-face :wk "face")
"hdF" '(describe-font :wk "font")
"hds" '(repeat-complex-command :wk "smart")
"hdt" '(describe-theme :wk "theme")
"hdp" '(describe-package :wk "package")
"hdC" '(describe-char :wk "char")
"hdG" '(general-describe-keybindings :wk "general")
"hdP" '(describe-personal-keybindings :wk "personal")

"hi" '(info :wk "info")
"he" '(view-echo-area-messages :wk "view echo")
"hs" '(use-package-report :wk "use-package report")
"hg" '(shortdoc-display-group :wk "shortdoc group")
"ho" '(nil :wk "online")
"hod" '(devdocs-search :wk "devdocs")))

(use-package info-colors
:hook
Expand Down
45 changes: 0 additions & 45 deletions init/keybindings-general.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
:states '(normal visual motion)
:keymaps 'override
"/" '(consult-ripgrep :wk "ripgrep") ; You'll need counsel package for this
;; "/" '(counsel-rg :wk "ripgrep") ; You'll need counsel package for this
"TAB" '(switch-to-prev-buffer :wk "previous buffer")
"SPC" '(execute-extended-command :wk "M-x")
;; "SPC" '(helm-M-x :wk "M-x")

;; Apps
"a" '(nil :wk "apps")
Expand All @@ -27,7 +25,6 @@
;; Buffers
"b" '(nil :wk "buffers")
"bb" '(switch-to-buffer :wk "to buffer (default)")
;; "bb" '(helm-buffers-list :wk "all")
"bp" '(projectile-switch-to-buffer :wk "in project")
"bP" '(projectile-switch-to-buffer-other-window :wk "in project other window")
"bd" '(kill-this-buffer :wk "kill this")
Expand Down Expand Up @@ -82,48 +79,6 @@
"fd" '(helm-projectile-find-dir :wk "find directory in project")
"fs" '(save-buffer :wk "save file")

;; Help
"h" '(nil :wk "help")
"hh" '(helpful-at-point :wk "at point (default)")
"hw" '(nil :wk "which-key")
"hwt" '((lambda () (interactive) (progn (which-key-mode)(which-key-posframe-mode))) :which-key "toggle on/off")
"hwr" '(which-key-show-top-level :wk "root")
"hwk" '(which-key-show-keymap :wk "keymap")
"hwM" '(which-key-show-full-major-mode :wk "major mode")
;; "hwM" '(which-key-show-major-mode :wk "major mode")
"hwm" '(which-key-show-full-minor-mode-keymap :wk "minor mode")
;; "hwm" '(which-key-show-minor-mode-keymap :wk "minor mode")
"hs" '(use-package-report :wk "use-package report")
"ha" '(nil :wk "apropos")
"haa" '(apropos :wk "apropos (default)")
"haw" '(apropos-all-words :wk "all")
"hac" '(apropos-command :wk "command")
"haf" '(apropos-function :wk "function")
"hav" '(apropos-variable :wk "variable")
"hd" '(nil :wk "describe")
"hdd" '(helpful-at-point :wk "token at point")
"hdv" '(helpful-variable :wk "variable")
"hdc" '(helpful-command :wk "command")
"hdf" '(helpful-callable :wk "function or macro")
"hdM" '(helpful-macro :wk "macro")
"hdm" '(describe-mode :wk "mode")
"hdk" '(helpful-key :wk "key")
"hdK" '(counsel-describe-map :wk "keymap")
"hdb" '(counsel-descbinds :wk "bindings")
"hda" '(describe-face :wk "face")
;; "hda" '(counsel-describe-face :wk "face")
"hdF" '(describe-font :wk "font")
"hds" '(repeat-complex-command :wk "smart")
"hdt" '(describe-theme :wk "theme")
"hdp" '(describe-package :wk "package")
"hdC" '(describe-char :wk "char")
"hdG" '(general-describe-keybindings :wk "general")
"hdP" '(describe-personal-keybindings :wk "personal")
"hi" '(info :wk "info")
"he" '(view-echo-area-messages :wk "view echo")
"ho" '(nil :wk "online")
"hod" '(devdocs-search :wk "devdocs")

;; Insert
"i" '(nil :wk "insert")
"ii" '(yas-insert-snippet :wk "default (snippet)")
Expand Down
2 changes: 1 addition & 1 deletion init/misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

;; TODO make it declarative
;; y/n instead of yes/no
(defalias 'yes-or-no-p 'y-or-n-p)
;; (defalias 'yes-or-no-p 'y-or-n-p) no longer needed in Emacs 28.1

;; Minimal UI in terminal as well
;; (if (fboundp 'scroll-bar-mode)
Expand Down
1 change: 1 addition & 0 deletions init/project-management.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(icostan/leader-keys
:states 'normal
"p" '(nil :wk "projects")
"ps" '(project-eshell :wk "shell")
"pr" '(project-dired :wk "root")))

(use-package consult-project-extra
Expand Down
2 changes: 2 additions & 0 deletions init/selection-vertico.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
("C-c s" . consult-ripgrep)
("C-c b" . consult-buffer))

(message "==> INIT: selection-vertico.el")

(provide 'selection-vertico)

;;; selection-vertico.el ends here
2 changes: 1 addition & 1 deletion init/spelling.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

(use-package flyspell
:config
(flyspell-mode)
(flyspell-prog-mode)
:general
(icostan/leader-keys
:states 'normal
Expand Down
4 changes: 3 additions & 1 deletion init/windows.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
;;; Code:

(use-package golden-ratio
:diminish "GR")
:diminish "GR"
:config
(golden-ratio-mode))

(use-package ace-window
:general
Expand Down
8 changes: 5 additions & 3 deletions langs/orgmode.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
("o" "org.d" checkitem (file+datetree "~/Projects/org.d/journal/20200601") (file "templates/org.d-todo.org"))))
(org-babel-do-load-languages
'org-babel-load-languages
'((ditaa . t)
'((calc . t)
(ditaa . t)
(emacs-lisp . t)
(js . t)
(haskell . t)
(ledger . t)
(latex . t)
(ledger . t)
(python . t)
(ruby . t)
(rust . t)
(sagemath . t)
(shell . t)
(sql . nil))))
(use-package ob-rust)

(use-package org-journal
:after org
Expand Down Expand Up @@ -82,6 +82,8 @@
:config
(org-evil-mode))

;; TRY: org-ref

(provide 'orgmode)

;;; orgmode.el ends here
3 changes: 3 additions & 0 deletions langs/rust.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
:custom
(rustic-format-trigger 'on-save))

(use-package ob-rust
:after orgmode)

(provide 'rust)

;;; rust.el ends here
6 changes: 3 additions & 3 deletions langs/sage.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
(sage-shell:use-prompt-toolkit nil)
:config
(sage-shell:define-alias))

(use-package ob-sagemath
:after sage-shell-mode
:custom
(org-babel-default-header-args:sage '((:results . "output"))))

(use-package helm-sage
:if (vanilla-helm-mode-p)
:after (helm sage-shell-mode)
:general
;; TODO: create a definer
(general-define-key
(icostan/leader-keys
:states '(normal visual insert emacs)
:prefix "SPC"
:non-normal-prefix "M-SPC"
Expand Down
69 changes: 69 additions & 0 deletions lisp/ob-ledger.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
;;; ob-ledger.el --- Babel Functions for Ledger -*- lexical-binding: t; -*-

;; Copyright (C) 2010-2021 Free Software Foundation, Inc.

;; Author: Eric S Fraga
;; Maintainer: Eric S Fraga
;; Keywords: literate programming, reproducible research, accounting
;; Homepage: https://orgmode.org

;; This file is not part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Org-Babel support for evaluating ledger entries.
;;
;; This differs from most standard languages in that
;;
;; 1) there is no such thing as a "session" in ledger
;;
;; 2) we are generally only going to return output from the ledger program
;;
;; 3) we are adding the "cmdline" header argument
;;
;; 4) there are no variables

;;; Code:
(require 'ob)

(defvar org-babel-default-header-args:ledger
'((:results . "output") (:cmdline . "bal"))
"Default arguments to use when evaluating a ledger source block.")

(defun org-babel-execute:ledger (body params)
"Execute a block of Ledger entries with org-babel.
This function is called by `org-babel-execute-src-block'."
(message "executing Ledger source code block")
(let ((cmdline (cdr (assq :cmdline params)))
(in-file (org-babel-temp-file "ledger-"))
(out-file (org-babel-temp-file "ledger-output-")))
(with-temp-file in-file (insert body))
(message "%s" (concat "ledger"
" -f " (org-babel-process-file-name in-file)
" " cmdline))
(with-output-to-string
(shell-command (concat "ledger"
" -f " (org-babel-process-file-name in-file)
" " cmdline
" > " (org-babel-process-file-name out-file))))
(with-temp-buffer (insert-file-contents out-file) (buffer-string))))

(defun org-babel-prep-session:ledger (_session _params)
(error "Ledger does not support sessions"))

(provide 'ob-ledger)

;;; ob-ledger.el ends here

0 comments on commit 3776ca2

Please sign in to comment.