X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=emacs.el;h=99c5e54ee65b8e569b8b0738040b4c17c830873e;hb=2439cdd60f235b3ccde4ddc47c740e3c9ee43b99;hp=47b66f34e19f4a15b425e6b4d4a3bd77a33e0f64;hpb=f021b824348ab525af737a879b8548ec4d84ca87;p=elisp.git diff --git a/emacs.el b/emacs.el index 47b66f3..99c5e54 100644 --- a/emacs.el +++ b/emacs.el @@ -31,9 +31,11 @@ ;; Xft.antialias: true ;; Xft.rgba: rgb -(set-default-font "Inconsolata 15") +;; (set-default-font "Inconsolata 15") -;; (set-default-font "Bitstream vera sans mono-12") +;; (package-initialize) + +(set-default-font "Bitstream vera sans mono-12") ;; (set-default-font "Liberation Mono-13") ;; (set-default-font "DejaVu sans mono 15") ;; (set-default-font "Droid sans mono 13") @@ -340,6 +342,7 @@ load-warning buffer in case of failure." (flyspell-mode)))) (add-hook 'c++-mode-hook 'flyspell-prog-mode) +;; (add-hook 'lua-mode-hook 'flyspell-prog-mode) (add-hook 'log-edit-mode-hook 'flyspell-mode) ;; I am a power-user @@ -386,14 +389,6 @@ load-warning buffer in case of failure." ;; "tool" bar? Are you kidding? (when (fboundp 'tool-bar-mode) (tool-bar-mode -1)) -;; ;; If my own letter icon is here, use it and change its color -;; (when (file-exists-p "~/local/share/emacs/letter.xbm") -;; (setq-default display-time-mail-icon -;; (find-image -;; '((:type xbm -;; :file "~/local/share/emacs/letter.xbm" -;; :ascent center))))) - ;; My funky setting of face colors. Basically, we switch to a sober ;; look and darken a bit the colors which need to (because of the ;; darker background) @@ -409,8 +404,6 @@ load-warning buffer in case of failure." ;; X-window (when window-system - ;; (setq - ;; display-time-use-mail-icon t) (ff/configure-faces '( @@ -461,8 +454,9 @@ load-warning buffer in case of failure." ;; (fringe :background "black" :foreground "gray90") (fringe :background "gray80") (ff/date-info-face :foreground "white") - (ff/battery-info-face :foreground "white") - (ff/mail-alarm-face :foreground "white" :background "red2") + (ff/battery-info-face :foreground "black") + (ff/battery-info-alarm-face :foreground "red") + ;; (ff/mail-alarm-face :foreground "white" :background "red2") ;; (alarm-vc-face :foreground "black" :background "yellow" :weight 'normal) (gui-button-face :background "green" :foreground "black") )) @@ -514,8 +508,9 @@ load-warning buffer in case of failure." :inverse-video nil) (region :background "white" :foreground "black") (ff/date-info-face :foreground "white" :weight 'bold) - (ff/battery-info-face :foreground "white") - (ff/mail-alarm-face :foreground "red" :weight 'bold) + (ff/battery-info-face :foreground "black") + (ff/battery-info-alarm-face :foreground "red") + ;; (ff/mail-alarm-face :foreground "red" :weight 'bold) (selector/selection :background "yellow") (gui-button-face :background "green" :foreground "white") (enotes/information-face :foreground "cyan") @@ -607,13 +602,6 @@ load-warning buffer in case of failure." ;; Playing sounds ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (defun ff/esd-sound (file) -;; "Plays a sound with the Enlighted sound daemon." -;; (interactive) -;; (process-kill-without-query (start-process-shell-command "esdplay" -;; nil -;; "esdplay" file))) - (defun ff/alsa-sound (file) "Plays a sound with ALSA." (interactive) @@ -867,40 +855,54 @@ printer." (error -1)) ) -(defun ff/temp-and-battery-info-string () (interactive) +(defun ff/temp-info-string () (interactive) (condition-case nil - (concat - - ;; The temperature + ;; The temperature + + (let ((temp (/ + (apply 'max (mapcar + (lambda (f) (string-to-number (ff/file-first-line f))) + ff/temperature-files)) + 1000))) + + (if (> temp 50) + (let ((s (format "%dC " temp))) + (if (> temp 70) + (propertize s 'face 'font-lock-warning-face) + s) + ) + ) + ) - (let ((temp (/ - (apply 'max (mapcar - (lambda (f) (string-to-number (ff/file-first-line f))) - ff/temperature-files)) - 1000))) + (error nil)) + ) - (if (> temp 50) - (let ((s (format "%dC " temp))) - (if (> temp 70) - (propertize s 'face 'font-lock-warning-face) - s) - ) +(defun ff/battery-info-string () (interactive) + (condition-case nil + (pcase (ff/battery-state ff/battery-dirs) + ;; (`charging (format "c%d%%" (ff/battery-percent))) + ;; (`discharging (format "d%d%%" (ff/battery-percent))) + ;; (`unknown "f") + + (`charging + (let ((p (ff/battery-percent))) + (if (> p 10) + (propertize (format "↑%d%%" p) 'face 'ff/battery-info-face) + (propertize (format "↑%d%%" p) 'face 'ff/battery-info-alarm-face)) ) ) - ;; The battery - - (pcase (ff/battery-state ff/battery-dirs) - ;; (`charging (format "c%d%%" (ff/battery-percent))) - ;; (`discharging (format "d%d%%" (ff/battery-percent))) - ;; (`unknown "f") - (`charging (format "↑%d%%" (ff/battery-percent))) - (`discharging (format "↓%d%%" (ff/battery-percent))) - (`unknown "✱") - (_ "?")) - - ) + (`discharging + (let ((p (ff/battery-percent))) + (if (> p 10) + (propertize (format "↓%d%%" p) 'face 'ff/battery-info-face) + (propertize (format "↓%d%%" p) 'face 'ff/battery-info-alarm-face)) + ) + ) + ;; (`unknown "✱") + (`unknown "F") + (_ "?")) (error nil)) ) @@ -949,46 +951,39 @@ printer." )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Make a sound when there is new mail +;; Display time ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; I do not like sounds anymore - -;; (setq ff/already-boinged-for-mail nil) +(setq -;; (defun ff/boing-if-new-mail () -;; (if mail (when (not ff/already-boinged-for-mail) -;; ;; (ff/play-sound-async "~/local/sounds/boing1.wav") -;; ;; (ff/show-unspooled-mails) -;; (setq ff/already-boinged-for-mail t)) -;; (setq ff/already-boinged-for-mail nil)) -;; ) + display-time-interval 10 ;; Check every 10s -;; (add-hook 'display-time-hook 'ff/boing-if-new-mail) + display-time-string-forms `( -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Display time -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + load -(setq + " " - display-time-interval 15 ;; Check every 15s + ,@(when (ff/temp-info-string) + '((ff/temp-info-string))) - display-time-string-forms `( + ,@(when (ff/battery-info-string) + '((ff/battery-info-string))) - load " " + ;; '((propertize + ;; (ff/battery-info-string) + ;; 'face 'ff/battery-info-face))) - (propertize - (ff/temp-and-battery-info-string) - 'face 'ff/battery-info-face) + " " (propertize - (concat " <" - 24-hours ":" minutes - " " - ;; dayname " " - monthname " " day - ">") + (concat ;;" ˌ" + 24-hours ":" minutes + " " + ;; dayname " " + monthname " " day + ;;"ˌ" + ) 'face 'ff/date-info-face) ) @@ -1697,6 +1692,26 @@ int main(int argc, char **argv) { ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun ff/start-lua () + "Adds all the stuff to start a new lua file" + (interactive) + (goto-char (point-min)) + (insert "#!/usr/bin/env luajit + +require 'torch' +require 'nn' +require 'nnx' +require 'optim' +require 'image' +require 'pl' +require 'paths' +require 'ffmpeg' + +") + (lua-mode) + ) + + (defun ff/start-html () "Adds all that stuff to start a new HTML file." (interactive) @@ -1890,6 +1905,11 @@ a file in /tmp" (ff/add-copyrights)) ) + (when (string-match "\\.lua$" filename) + (lua-mode) + (ff/start-lua) + ) + (when (string-match "\\.html$" filename) (html-mode) (ff/start-html) @@ -1950,19 +1970,6 @@ a file in /tmp" (define-key global-map [f8] 'ff-find-other-file) (define-key global-map [(shift f8)] (lambda () (interactive) (ff-find-other-file t))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Antiword, htmlize and boxquote -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(autoload 'no-word "no-word") -(add-to-list 'auto-mode-alist '("\\.doc\\'" . no-word)) -;; (add-to-list 'auto-mode-alist '("\\.DOC\\'" . no-word)) - -(autoload 'htmlize-buffer "htmlize" nil t) - -(setq boxquote-top-and-tail "------------------") -(autoload 'boxquote-region "boxquote" nil t) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The compilation hacks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2016,7 +2023,7 @@ a file in /tmp" compile-history '("make clean" "make DEBUG=yes -j -k" "make -j -k") ) -(defun ff/universal-compile () (interactive) +(defun ff/universal-compile (universal) (interactive "P") (funcall (or (cdr (assoc major-mode '( (latex-mode . tex-file) @@ -2119,7 +2126,7 @@ This may be a useful alternative binding for \\[delete-other-windows] (while (re-search-forward "[0-9\.]+" nil t) (let ((value (string-to-number (buffer-substring (match-beginning 0) (match-end 0))))) (delete-region (match-beginning 0) (match-end 0)) - (insert (format "%0.2f" value))))))) + (insert (format "%0.1e" value))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Keymaping @@ -2318,7 +2325,7 @@ next one. With universal argument, kill all killable buffers." "svn-commit.tmp$" ".git/COMMIT_EDITMSG$" "\.bbl$" "\.aux$" "\.toc$" )) - recentf-max-saved-items 1000 + recentf-max-saved-items 10000 recentf-save-file (concat ff/emacs-dir "/recentf") ) @@ -2356,6 +2363,7 @@ next one. With universal argument, kill all killable buffers." media/duration-to-history 30 media/history-size 1000 media/playlist-file (concat ff/emacs-dir "/media-playlists") + media/continue-mode-hint (if window-system "⤸" "*") media/mplayer/args '( "-framedrop" "-zoom" @@ -2366,6 +2374,7 @@ next one. With universal argument, kill all killable buffers." ) media/mplayer/timing-request-period 1.0 ) + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2532,6 +2541,12 @@ with a time tag, and save this file" (define-key esc-map "`" ff/map) +(defun ff/kill-downto-signature () (interactive) + (let ((s (point))) + (when (re-search-forward "^-- $") + (kill-region s (match-beginning 0)) + (goto-char s)))) + (defun ff/git-status (&optional dir) (interactive) (if (buffer-file-name) (git-status (file-name-directory (buffer-file-name))) @@ -2582,6 +2597,7 @@ with a time tag, and save this file" (bookmark-save))) (define-key ff/map "f" 'ff/move-region-to-fridge) (define-key ff/map [(control f)] 'ff/flyspell-mode) +(define-key ff/map [(control k)] 'ff/kill-downto-signature) (define-key ff/map [?\C-0] 'ff/delete-annoying-windows) (define-key ff/map "1" 'delete-other-windows)