X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=emacs.el;h=eaa1011d1e7b7b37b83b28211d36c3a5d89a744f;hb=7a17c8bf041a7c222b217b53d36647eaff2ba3d7;hp=23ca425186643a733cb21d0caf3aab3d51f0a4e4;hpb=87b171d58f0b3afc82d8842f2bd01cdc1c367360;p=elisp.git diff --git a/emacs.el b/emacs.el index 23ca425..eaa1011 100644 --- a/emacs.el +++ b/emacs.el @@ -18,6 +18,15 @@ ;; Contact for comments & bug reports ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Ugly hack because 23.2 is not installed properly in my Debian + +(when (and (>= emacs-major-version 23) + (>= emacs-minor-version 2)) + (add-to-list 'load-path "/usr/share/emacs/site-lisp/vm/") + (add-to-list 'load-path "/usr/share/emacs/site-lisp/bbdb/lisp/") + (add-to-list 'load-path "/usr/share/emacs/site-lisp/mailcrypt/") +) + ;; It's better to set the preferences in the .Xresources so that the ;; window is not first displayed with the wrong options @@ -390,7 +399,6 @@ load-warning buffer in case of failure." :inverse-video nil) (mode-line-inactive :background "gray60" :foreground "black" :box nil :inverse-video nil) - ;; (tex-verbatim :family nil) (region :background "springgreen2") (ff/date-info-face :foreground "white" :weight 'bold) (ff/mail-alarm-face :foreground "red" :weight 'bold) @@ -405,8 +413,8 @@ load-warning buffer in case of failure." ;; (ff/configure-faces '((default :background "gray80" :foreground "black"))) (when window-system - (setq - display-time-use-mail-icon t) + ;; (setq + ;; display-time-use-mail-icon t) (ff/configure-faces '( @@ -451,6 +459,7 @@ load-warning buffer in case of failure." :inverse-video nil) ;; (fringe :background "black" :foreground "gray90") (fringe :background "gray65") + (tex-verbatim :family "courrier") (ff/date-info-face :foreground "white" :weight 'bold) (ff/mail-alarm-face :foreground "white" :background "red2") ;; (alarm-vc-face :foreground "black" :background "yellow" :weight 'normal) @@ -650,10 +659,10 @@ occurrences " (setq ps-print-color-p nil ;; ps-paper-type 'letter ps-paper-type 'a4 - ps-top-margin (* 1.75 56.692) - ps-left-margin 56.692 - ps-bottom-margin 56.692 - ps-right-margin 56.692 + ;; ps-top-margin (* 1.75 56.692) + ;; ps-left-margin 56.692 + ;; ps-bottom-margin 56.692 + ;; ps-right-margin 56.692 ;; Simple header. Remove that silly frame shadow. ps-print-header nil @@ -672,6 +681,26 @@ occurrences " ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; http://blog.tuxicity.se/elisp/emacs/2010/03/26/rename-file-and-buffer-in-emacs.htm + +(defun rename-file-and-buffer () + "Renames current buffer and file it is visiting." + (interactive) + (let ((name (buffer-name)) + (filename (buffer-file-name))) + (if (not (and filename (file-exists-p filename))) + (message "Buffer '%s' is not visiting a file!" name) + (let ((new-name (read-file-name "New name: " filename))) + (cond ((get-buffer new-name) + (message "A buffer named '%s' already exists!" new-name)) + (t + (rename-file name new-name 1) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil))))))) + +(global-set-key (kbd "C-c r") 'rename-file-and-buffer) + (defun ff/non-existing-filename (dir prefix suffix) "Returns a filename of the form DIR/PREFIX[.n].SUFFIX whose file does not exist" @@ -846,7 +875,7 @@ printer." (propertize (with-temp-buffer (apply 'call-process x) (buffer-string)) - 'face 'highlight) + 'face '(:background "gray80")) (with-temp-buffer (apply 'call-process x) (buffer-string)) )) @@ -896,6 +925,7 @@ printer." display-time-interval 15 ;; Check every 15s display-time-string-forms `( + ;; (if mail ;; (concat " " ;; (propertize " mail " @@ -1367,6 +1397,10 @@ universal argument starts xfig even if the .fig does not exist" (when (ff/load-or-alert "lookup-dict" t) (define-key global-map [(control \?)] 'lookup-dict)) +;; (defun ff/generate-password () (interactive) + ;; (let ((c "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-")) + ;; (nth (random (length c)) c)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Automatization of things I do often ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1396,15 +1430,26 @@ universal argument starts xfig even if the .fig does not exist" %% \\usepackage{hyperref} %% \\usepackage{harvard} +\\setlength{\\parindent}{0cm} +\\setlength{\\parskip}{12pt} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Sans serif fonts %% \\usepackage[T1]{fontenc} %% \\usepackage[scaled]{helvet} %% \\usepackage[cm]{sfmath} %% \\renewcommand{\\ttdefault}{pcr} %% \\renewcommand*\\familydefault{\\sfdefault} - -\\setlength{\\parindent}{0cm} -\\setlength{\\parskip}{12pt} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draft layout +%% \\setlength{\\parindent}{1cm} +%% \\renewcommand{\\baselinestretch}{2.0} +%% \\setlength{\\oddsidemargin}{-0.6cm} +%% \\setlength{\\evensidemargin}{0cm} +%% \\setlength{\\textwidth}{17.5cm} +%% \\setlength{\\textheight}{23cm} +%% \\setlength{\\topmargin}{-1.5cm} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% \\renewcommand{\\baselinestretch}{1.3} @@ -1457,6 +1502,14 @@ universal argument starts xfig even if the .fig does not exist" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun ff/remove-ip-header () (interactive) + (save-excursion + (goto-char (point-min)) + (when (and (re-search-forward "START_IP_HEADER" nil t) + (re-search-forward "END_IP_HEADER" nil t)) + (message "yep")) + )) + (defun ff/add-gpl () "Adds the GPL statements at the beginning of current buffer." (interactive) @@ -1517,6 +1570,24 @@ END_IP_HEADER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun ff/start-c () + "Adds the header to start a C program." + (interactive) + ;; (beginning-of-buffer) + (insert + " +#include +#include + +int main(int argc, char **argv) { + exit(EXIT_SUCCESS); +} +") + (previous-line 2) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defun ff/start-c++ () "Adds the header to start a C++ program." (interactive) @@ -1545,7 +1616,7 @@ int main(int argc, char **argv) { (interactive) (let ((flag-name (replace-regexp-in-string "[\. \(\)]" "_" - (upcase (file-name-nondirectory (buffer-name)))))) + (upcase (file-name-nondirectory (buffer-file-name)))))) (goto-char (point-max)) (insert "\n#endif\n") (goto-char (point-min)) @@ -1757,6 +1828,11 @@ a file in /tmp" (previous-line 1) ) + (when (string-match "\\.c$" filename) + (c-mode) + (ff/add-copyrights) + (ff/start-c)) + (when (string-match "\\.cc$" filename) (c++-mode) (ff/add-copyrights) @@ -2204,6 +2280,7 @@ next one. With universal argument, kill all killable buffers." "-framedrop" "-zoom" "-subfont-osd-scale" "3" + ;; "-stop-xscreensaver" ;; "-osdlevel" "3" ) media/mplayer/timing-request-period 5.0 @@ -2334,6 +2411,7 @@ proposes to visit them." (define-key ff/map [(control g)] 'ff/git-status) (define-key ff/map [(control w)] 'server-edit) (define-key ff/map [(control d)] 'ff/elisp-debug-on) +(define-key ff/map "d" 'diary) (define-key ff/map [(control \`)] 'ff/bash-new-buffer) (define-key ff/map [(control n)] 'enotes/show-all-notes) (define-key ff/map [(control s)] 'ff/secure-note-add) @@ -2345,6 +2423,7 @@ proposes to visit them." (define-key ff/map [(control c)] 'calendar) ;; (define-key ff/map [(control c)] (lambda () (interactive) (save-excursion (calendar)))) (define-key ff/map [(control l)] 'goto-line) +(define-key ff/map "l" 'longlines-mode) (define-key ff/map [(control o)] 'selector/quick-pick-recent) (define-key ff/map "s" 'selector/quick-move-in-buffer) (define-key ff/map "S" 'selector/search-sentence) @@ -2546,7 +2625,9 @@ With argument ARG, do this that many times." (when (ff/load-or-alert "enotes" t) (setq enotes/file "~/private/enotes" enotes/show-help nil - enotes/full-display nil) + enotes/full-display nil + enotes/default-time-fields "9:30") + (enotes/init) ;; (add-hook 'enotes/alarm-hook ;; (lambda () (ff/play-sound-async "~/local/sounds/three_notes2.wav")))