summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic.el37
-rw-r--r--common.el9
-rw-r--r--completion-conf.el2
-rw-r--r--dashboard.el2
-rw-r--r--desktop-conf.el4
-rw-r--r--org-conf.el54
-rw-r--r--view-conf.el95
7 files changed, 195 insertions, 8 deletions
diff --git a/basic.el b/basic.el
index fc1740e..431c05a 100644
--- a/basic.el
+++ b/basic.el
@@ -97,6 +97,7 @@
'((width . 118)))
(set-frame-width nil 118)
(add-to-list 'default-frame-alist '(width . 118))
+(add-to-list 'default-frame-alist '(height . 35))
(add-to-list 'default-frame-alist '(font . "Droid Sans Mono for Powerline-20"))
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
@@ -105,6 +106,42 @@
(setq revert-without-query '(".*"))
(set-face-attribute 'variable-pitch nil :family "Avenir" :height 1.0)
+;;; Adjust default size
+
+;;;###autoload
+(defvar durand-frame-width-pixel 1420
+ "Default frame width in pixels.
+Set the frame to this width in order to fill my screen.")
+
+;;;###autoload
+(defvar durand-frame-height-pixel 842
+ "Default frame height in pixels.
+Set the frame to this height in order to fill my screen.")
+
+;;;###autoload
+(defun durand-adjust-font-size (delta)
+ "Increase the default font size by DELTA.
+If DELTA is negative, decrease the size by (- DELTA).
+
+This will maintain the frame's width and height as well."
+ (let* ((width durand-frame-width-pixel)
+ (height durand-frame-height-pixel)
+ (current-font (face-attribute 'default :font))
+ (font-name (aref (query-font current-font) 0))
+ (current-height
+ (progn
+ (string-match
+ "[[:alpha:]-*]+\\([[:digit:]]+\\)"
+ font-name)
+ (string-to-number (match-string 1 font-name))))
+ (new-name (replace-match (number-to-string (+ delta current-height))
+ nil nil font-name 1)))
+ (set-face-attribute 'default nil :font new-name)
+ (set-frame-width (selected-frame) width nil t)
+ (set-frame-height (selected-frame) height nil t)))
+
+(durand-hide-minor-mode buffer-face-mode face-remap "BF")
+
;;; disable line numbers, as that is a performace killer for me.
(setq-default display-line-numbers-type nil)
diff --git a/common.el b/common.el
index 3b75063..25b775d 100644
--- a/common.el
+++ b/common.el
@@ -186,11 +186,14 @@ ARG means do this command ARG times."
;;; Hide some minor mode from the mode line display.
;;;###autoload
-(defmacro durand-hide-minor-mode (minor &optional to-require)
+(defmacro durand-hide-minor-mode (minor &optional to-require light)
"Hide MINOR from the mode line.
-Require TO-REQUIRE so that we don't have errors."
+Require TO-REQUIRE so that we don't have errors.
+
+Optional LIGHT means to use the lighter name instead of
+completely hiding it."
(cond (to-require (require to-require)))
- `(setcdr (assq ',minor minor-mode-alist) (list "")))
+ `(setcdr (assq ',minor minor-mode-alist) (list (or ,light ""))))
(provide 'common)
;;; common.el ends here.
diff --git a/completion-conf.el b/completion-conf.el
index e567eb7..1ae21e2 100644
--- a/completion-conf.el
+++ b/completion-conf.el
@@ -31,7 +31,7 @@
(require 'minibuffer)
(require 'simple)
-(setq completion-styles '(substring partial-completion flex))
+(setq completion-styles '(initials substring partial-completion flex))
(setq completion-category-defaults nil)
(setq completion-flex-nospace nil)
(setq completion-pcm-complete-word-inserts-delimiters t)
diff --git a/dashboard.el b/dashboard.el
index e2e3669..0a4402e 100644
--- a/dashboard.el
+++ b/dashboard.el
@@ -21,7 +21,7 @@
(center-string-in-width
(propertize " " 'display image 'rear-nonsticky '(display))
(round (- (window-body-width)
- (* (car (image-size image)) 1))))))
+ (* (car (image-size image)) 0.7))))))
(newline 5)
(insert
(center-string-in-width
diff --git a/desktop-conf.el b/desktop-conf.el
index 2439c10..4762f42 100644
--- a/desktop-conf.el
+++ b/desktop-conf.el
@@ -1,6 +1,6 @@
(setq desktop-auto-save-timeout 600)
-(setq desktop-dirname "/Users/durand/Desktop/emacs.d/")
-(setq desktop-path '("/Users/durand/Desktop/emacs.d/"))
+(setq desktop-dirname "/Users/durand/.emacs.d/")
+(setq desktop-path '("/Users/durand/.emacs.d/"))
(setq desktop-base-file-name "desktop")
(setq desktop-files-not-to-save nil)
(setq desktop-globals-to-clear nil)
diff --git a/org-conf.el b/org-conf.el
index aafbc8d..c9e2cf5 100644
--- a/org-conf.el
+++ b/org-conf.el
@@ -32,7 +32,7 @@
(define-key org-mode-map (vector 3 ?\S-l) #'org-toggle-link-display)
(define-key org-mode-map (vector 3 ?\C-\S-l) #'org-insert-last-stored-link)
-(declare-function 'durand-pulse-pulse-line "~/Desktop/emacs.d/basic.el")
+(declare-function 'durand-pulse-pulse-line "~/.emacs.d/basic.el")
(add-hook 'org-follow-link-hook #'durand-pulse-recenter-top)
@@ -260,6 +260,8 @@ in Lisp code use `org-set-tags' instead."
(format "%s\n :PROPERTIES:\n :cost: %s\n :FROM: %s\n :RECORD_TIME: %s\n :END: \n %s%%?"
which cost from inactive-time shop-and-items)))
+(require 'org-ptotocol)
+
(setq org-capture-templates
'(("d" "Record Diaries" entry
(file+olp+datetree "~/org/diary.org")
@@ -458,3 +460,53 @@ in Lisp code use `org-set-tags' instead."
":web_link:stack:")
(t
":web_link:"))))
+
+;;;###autoload
+(defun org-update-novels (&optional desc)
+ "Update the html link to a novel, or to a web_link.
+If DESC is non-`nil', then it is the description of the new link."
+ (interactive)
+;;; HACK: Refocus the selected frame.
+;;; I was doing this in the applescript. But for some reason it is messed up. So
+;;; I let emacs gain focus by itself now.
+ (select-frame-set-input-focus (selected-frame))
+ (let* ((tags (completing-read "tag: " '("roman-ARCHIVE"
+ "web_link-ARCHIVE")
+ nil t))
+ (roman-p (string-match "roman" tags))
+ (files '("/Users/durand/org/notes.org" "/Users/durand/org/math_article_links.org"))
+ (prompt (if roman-p
+ "Chois un roman à mettre à jour: "
+ "Chois un web lien à mettre à jour: "))
+ cands)
+ (setf cands
+ (cl-loop for file in files
+ append (with-current-file file nil
+ (org-map-entries
+ (lambda ()
+ (let ((orig (durand-org-link-info t)))
+ (list (car orig) (cdr orig) file)))
+ tags))))
+ (unless roman-p (setf cands (nreverse cands)))
+ (let* ((choix (completing-read prompt cands nil t))
+ (item (cl-assoc choix cands :test #'string=))
+ (lien (read-string "Le lien: " (current-kill 0 t))))
+ (with-current-file (caddr item) nil
+ (goto-char (cadr item))
+ (org-update-link lien nil nil desc)))))
+
+;;; filter out the title
+
+;;;###autoload
+(defun org-filter-title ()
+ "Filter out some unnecessary parts of the link title"
+ (let ((title (plist-get org-store-link-plist :description)))
+ (cond
+ ((string-match " - Mathematics Stack Exchange" title)
+ (replace-match "" nil nil title))
+ ((string-match " - YouTube" title)
+ (replace-match "" nil nil title))
+ ((string-match "\\(.*?\\)最新章节列表,\\1无弹窗_UU看书" title)
+ (replace-match "\\1" nil nil title))
+ (t
+ title))))
diff --git a/view-conf.el b/view-conf.el
index 5465b89..0f0ef29 100644
--- a/view-conf.el
+++ b/view-conf.el
@@ -223,3 +223,98 @@ options to choose from."
(kill-new
(concat "https://www.youtube.com/watch?v="
(substring-no-properties video-name -11))))))
+
+;;; Wifi and Bluetooth handling
+
+;;;###autoload
+(defvar durand-wifi-on-p nil
+ "If WIFI is on or not.
+This is defined in \"/Users/durand/.emacs.d/view-conf.el\"")
+
+;;;###autoload
+(defvar durand-bluetooth-on-p nil
+ "If BLUETOOTH is on or not.
+This is defined in \"/Users/durand/.emacs.d/view-conf.el\"")
+
+;;;###autoload
+(defun durand-wifi-filter (proc output)
+ "Filter function to set the wifi variable.
+This should only be used for the process \"durand-wifi\".
+This is defined in \"/Users/durand/.emacs.d/view-conf.el\""
+ (cond
+ ((string= (process-name proc) "durand-wifi"))
+ ((user-error "Filter function associated with a wrong process.")))
+ (setq durand-wifi-on-p (string-match "On$" output)))
+
+;;;###autoload
+(defun durand-bluetooth-filter (proc output)
+ "Filter function to set the bluetooth variable.
+This should only be used for the process \"durand-bluetooth\".
+This is defined in \"/Users/durand/.emacs.d/view-conf.el\""
+ (cond
+ ((string= (process-name proc) "durand-bluetooth"))
+ ((user-error "Filter function associated with a wrong process.")))
+ (setq durand-bluetooth-on-p (string-match "1" output)))
+
+;;;###autoload
+(defun durand-wifi-or-bluetooth (&optional arg)
+ "Check if WIFI is enabled, then ask for confirmation to toggle WIFI.
+If ARG is non-nil, do the same for Bluetooth."
+ (interactive "P")
+ (cond
+ ((null arg)
+ (make-process
+ :name "durand-wifi"
+ :buffer nil
+ :command '("networksetup" "-getairportpower" "en0")
+ :filter #'durand-wifi-filter
+ :sentinel #'ignore)
+ (accept-process-output (get-process "durand-wifi"))
+ (let* ((prompt (format "WIFI is %s. Do you want to turn WIFI %s"
+ (cond (durand-wifi-on-p "on")
+ ("off"))
+ (cond (durand-wifi-on-p "off?")
+ ("on?"))))
+ (decision (y-or-n-p prompt)))
+ (cond
+ (decision
+ (let ((new-state (cond (durand-wifi-on-p "off")
+ ("on"))))
+ (make-process
+ :name "durand-toggle-wifi"
+ :buffer nil
+ :command (list
+ "networksetup" "-setairportpower"
+ "en0" new-state)
+ :sentinel #'ignore
+ :filter #'ignore)
+ (message "WIFI turned %s" new-state))))))
+ (t
+ (make-process
+ :name "durand-bluetooth"
+ :buffer nil
+ :command '("blueutil" "-p")
+ :filter #'durand-bluetooth-filter
+ :sentinel 'ignore)
+ (accept-process-output (get-process "durand-bluetooth"))
+ (let* ((prompt (format "BLUETOOTH is %s. Do you want to turn BLUETOOTH %s"
+ (cond (durand-bluetooth-on-p "on")
+ ("off"))
+ (cond (durand-bluetooth-on-p "off?")
+ ("on?"))))
+ (decision (y-or-n-p prompt)))
+ (cond
+ (decision
+ (let ((new-state (cond (durand-bluetooth-on-p "0")
+ ("1"))))
+ (make-process
+ :name "durand-toggle-bluetooth"
+ :buffer nil
+ :command (list "blueutil" "-p" new-state)
+ :sentinel 'ignore
+ :filter 'ignore)
+ (message "BLUETOOTH turned %s"
+ (cond (durand-bluetooth-on-p "off")
+ ("on"))))))))))
+
+(define-key global-map (vector 3 ?w) #'durand-wifi-or-bluetooth)