[Misc] Remove db-emacsclient.el and distribute functions to other files

This commit is contained in:
Daniel - 2018-11-18 15:37:58 +01:00
parent 3380369f5b
commit f6c7a408db
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
4 changed files with 36 additions and 64 deletions

10
init.el
View File

@ -526,9 +526,9 @@
hydra-ispell/body
hydra-toggle/body
hydra-zoom/body
hydra-rectangle/body))
(use-package db-emacsclient)
hydra-rectangle/body
db/two-monitors-xrandr
db/one-monitor-xrandr))
(use-package hydra
:commands (defhydra))
@ -581,6 +581,10 @@
db/find-parent-task
db/ensure-running-clock
db/save-current-org-task-to-file
db/org-clock-out
db/org-clock-in-break-task
db/org-clock-in-home-task
db/org-clock-in-work-task
endless/org-ispell
db/update-org-agenda-files
db/org-agenda-list-deadlines

View File

@ -1,61 +0,0 @@
;;; db-emacsclient.el --- Execute functions called from emacsclient -*- lexical-binding: t -*-
;;; Commentary:
;;
;;
;;; Code:
(defvar db/emacsclient-map (make-sparse-keymap)
"Keymap used for keys called from emacsclient.")
(defun db/emacsclient-key (key)
"Run command associated with `KEY' in `db/emacsclient-map'."
(let ((function (lookup-key db/emacsclient-map key)))
(when function (apply function nil))))
(define-key db/emacsclient-map "w"
(lambda ()
(interactive)
(clock-in-task-by-id org-working-task-id)
;;; FIXME: duplicate code
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto")
(call-process "xkbcomp" nil nil nil
"-I" "$HOME/.local/share/xkb/"
"~/.local/share/xkb/keymap/xkbtest $DISPLAY")))
(define-key db/emacsclient-map "2"
(lambda ()
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto")
(call-process "xkbcomp" nil nil nil
"-I" "$HOME/.local/share/xkb/"
"~/.local/share/xkb/keymap/xkbtest $DISPLAY")))
(define-key db/emacsclient-map "o"
#'org-clock-out)
(define-key db/emacsclient-map "b"
(lambda ()
(interactive)
(clock-in-task-by-id org-break-task-id)))
(define-key db/emacsclient-map "h"
(lambda ()
(interactive)
(clock-in-task-by-id org-home-task-id)
;;; FIXME: duplicate code
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--off")))
(define-key db/emacsclient-map "1"
(lambda ()
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--off")))
;;;
(provide 'db-emacsclient)
;;; db-emacsclient.el ends here

View File

@ -302,6 +302,22 @@ In ~%s~:
(insert "No running clock")
(insert org-clock-heading)))))
(defun db/org-clock-out ()
"Clock out current clock."
(org-clock-out))
(defun db/org-clock-in-break-task ()
"Clock into default break task as given by `org-break-task-id."
(db/clock-in-task-by-id org-break-task-id))
(defun db/org-clock-in-home-task ()
"Clock into default home task as given by `org-home-task-id."
(db/clock-in-task-by-id org-home-task-id))
(defun db/org-clock-in-work-task ()
"Clock into default work task as given by `org-work-task-id."
(db/clock-in-task-by-id org-working-task-id))
;;; Fixes

View File

@ -495,6 +495,19 @@ _h_ _l_ _o_k _y_ank
("e" rectangle-exchange-point-and-mark nil)
("o" nil nil))
;;; Wrappers for external applications
(defun db/two-monitors-xrandr ()
"Activate second monitor using xrandr."
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto"))
(defun db/one-monitor-xrandr ()
"Deactivate all additional monitors."
(call-process "xrandr" nil nil nil
"--output" "HDMI-3" "--off"))
;;; End