diff --git a/emacs b/emacs new file mode 100644 index 0000000..64ca2f4 --- /dev/null +++ b/emacs @@ -0,0 +1,582 @@ +;;;;;;;;;;;;;;;;;;;;;; +;; Customs Iniziali ;; +;;;;;;;;;;;;;;;;;;;;;; + +(custom-set-variables + '(case-fold-search t) + '(current-language-environment "English") + '(uniquify-buffer-name-style (quote forward) nil (uniquify))) +(custom-set-faces + ) + +;; No splash screen, thank you kindly +(setq inhibit-startup-message t) + +;; No beep +(setq visible-bell t) + +;; y e n invece che yes e no +(fset 'yes-or-no-p 'y-or-n-p) + +;; Dont ask me if i want to use those commands +;; disabilitati di default +(put 'downcase-region 'disabled nil) +(put 'upcase-region 'disabled nil) + +;; Carica Lisp path +(setq load-path (cons "~/.emacs.d/lisp/" load-path)) + +;; Carica themes path +(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") + +;; Debug errors +;(setq debug-on-error t) + +;; Set default mode (anche no) +;(setq default-major-mode 'write-mode) + +;;;;;;;;;;;;;;;;;; +;; Backup Files ;; +;;;;;;;;;;;;;;;;;; + +;; Non creare files di backup +;(setq make-backup-files nil) + +;; Disattiva l'autosave +(setq auto-save-default nil) + +;; Intervallo dell'autosave +;(setq-default auto-save-interval 0) + +;; Delete unnecessary autosave files +(setq delete-auto-save-files t) + +;; Delete oldversion files +;(setq delete-old-versions t) + +;; Setta la directory di backup +(setq backup-directory-alist `(("." . "~/.saves"))) + +;; Backup tramite hardcopy +(setq backup-by-copying t) + +;; Quante copie? 2 antiche e 6 nuove per totale di 8 +(setq delete-old-versions t + kept-new-versions 6 + kept-old-versions 2 + version-control t) + +;; Non backuppare i *.gpg +(defvar my-backup-ignore-regexps (list "\\.gpg$") + "*List of filename regexps to not backup") +(defun my-backup-enable-p (name) + "Filter certain file backups" + (when (normal-backup-enable-predicate name) + (let ((backup t)) + (mapc (lambda (re) + (setq backup (and backup (not (string-match re name))))) + my-backup-ignore-regexps) + backup))) +(setq backup-enable-predicate 'my-backup-enable-p) + +;;;;;;;;;;;;;;;;;;;;;; +;; Saving sessions ;;; +;;;;;;;;;;;;;;;;;;;;;; + +;; open automaticamente that particular file +; (find-file "/home/dan/foo.md") + +;; Remember last session +;(desktop-save-mode 1) +;; Per disattivare: M-x desktop-clear + +;;;;;;;;;;;;;;;;; +;; Emacs Screen: +;; +;; | title bar of terminal window +;; | menu bar +;; | +;; | buffer +;; | +;; | mode line +;; | minibuffer +;;;;;;;;;;;;;;;;; + +;; Show buffer name in title-bar per xterm +;(setq frame-title-format "emacs - %b") + +;; No menubar +(menu-bar-mode -1) + +;; Se menubar is on (default) la usi con il mouse in xemacs +;; e con F10 e le frecce in terminale. +;; usa la menubar via keys +;(setq tty-menu-open-use-tmm t) + +;; Add a new menubar element +;(define-key-after (lookup-key global-map [menu-bar edit]) +; [startup] '("Toggle Truncate Lines" . (lambda () (interactive) +; (setq-default truncate-lines (not truncate-lines)))) [calendar]) + +;; Buffer: quanto e' una tab +(setq-default tab-width 4) + +;; usa spazi invece che tabs +(setq-default indent-tabs-mode nil) + +;; attiva il wrap. il default e' 70 chars +(add-hook 'text-mode-hook 'turn-on-auto-fill) + +;; Quanto wrap? facciamo 80 +;; C-u 60 C-x f, ma anche C-x f 60 +(add-hook 'text-mode-hook '(lambda () (setq fill-column 80))) + +;; Scroll just one line +(setq scroll-step 1) + +;; Down arrow wont insert newline +(setq-default next-line-add-newlines nil) + +;; Large margins when writing prose +(defun my-set-margins () + "Set margins in current buffer." + (setq left-margin-width 3) + (setq right-margin-width 2)) +(add-hook 'markdown-mode-hook 'my-set-margins) +;(add-hook 'text-mode-hook 'my-set-margins) + +;; Niente scrollbar per xterm +;(tool-bar-mode nil) +;(toggle-scroll-bar -1) + +;;;;;;;;;;;;;;; +;; Mode line ;; +;;;;;;;;;;;;;;; + +;; Column number highlighting on +(column-number-mode t) + +;; Show line number +(setq-default line-number-mode t) + +;; Show buffer and region size indication +(size-indication-mode 1) + +;; Show auto numero di caratteri in region +(require 'modeline-posn) + +;; Show file path in mode line con C-c z +(defun show-file-name () + "Show the full path file name in the minibuffer." + (interactive) + (message (buffer-file-name)) + (kill-new (file-truename buffer-file-name)) + ) +(global-set-key "\C-cz" 'show-file-name) + +; Show time +(display-time-mode 1) + +;(defface egoge-display-time +; '((((type x w32 mac)) +; ;; #060525 is the background colour of my default face. +; (:foreground "#060525" :inherit bold)) +; (((type tty)) +; (:foreground "blue"))) +; "Face used to display the time in the mode line.") + +(defface pretty-display-time + '((((type tty)) + (:foreground "blue"))) + "Face used to display the time in the mode line.") + +;; Time in the modeline to be displayed in `pretty-display-time-face' +(setq display-time-string-forms + '((propertize (concat " " 24-hours ":" minutes " ") + 'face 'pretty-display-time))) + +; Show battery indicator +(display-battery-mode 1) + +;; Show chars/words in region/buffer +;; count-words-region/buffer e count-char-region/buffer +(defun count-words-buffer () + (interactive) + (save-excursion + (let ((count 0)) + (goto-char (point-min)) + (while (< (point) (point-max)) + (forward-word 1) + (setq count (1+ count))) + (message "il buffer contiene %d words." count)))) + +(defun count-words-region (start end) + (interactive "r") + (save-excursion + (let ((count 0)) + (goto-char start) + (while (< (point) end ) + (forward-word 1) + (setq count (1+ count))) + (message "la regione contiene %d words." count)))) + +(defun count-char-buffer () + (interactive) + (save-excursion + (let ((count 0)) + (goto-char (point-min)) + (while (< (point) (point-max)) + (forward-char 1) + (setq count (1+ count))) + (message "il buffer contiene %d characters." count)))) + +(global-set-key "\e\e\c" 'count-char-buffer) + +(defun count-char-region (start end) + (interactive "r") + (save-excursion + (let ((count 0)) + (goto-char start) + (while (< (point) end ) + (forward-char 1) + (setq count (1+ count))) + (message "la regione contiene %d characters." count)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Colori ed Evidenziatori ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; ZenBurn Theme +(load-theme 'zenburn t) + +;; Highlight search and replace +(setq query-replace-highlight t) +(setq search-highlight t) + +;; Highlight marked region +(transient-mark-mode t) + +;; Highlight current line +;(set-face-attribute hl-line-face nil :underline t) + +;; Highlight matching parenthesis +;(require 'paren) +;(show-paren-mode t) + +;; Highlight l'ultima linea prima di scrollare via +(require 'highlight-context-line) + +;;;;;;;;;;;;;; +;; MARKDOWN ;; +;;;;;;;;;;;;;; + +(autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) +(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) +(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) + +;; Usa pandoc per la conversione in html: C-c C-c c +(defun convert-markdown-to (newtype) + (interactive "sOutput[html|html5|rtf|slidy|mediawiki|revealjs|latex|..]: ") + (let ((current-document (buffer-file-name)) + (temp-filename (concat "./output." newtype))) + (with-temp-file temp-filename + (call-process-shell-command (concat "pandoc -s -f markdown -t " newtype) + nil t nil current-document)) + (browse-url temp-filename))) +(eval-after-load "markdown-mode" + '(define-key markdown-mode-map (kbd "C-c C-c c") 'convert-markdown-to)) + +;;;;;;;;;;;;;; +;; ORG MODE ;; +;;;;;;;;;;;;;; + +(require 'org) +(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) +(define-key global-map "\C-cl" 'org-store-link) +(define-key global-map "\C-ca" 'org-agenda) +(setq org-log-done t) + +;(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on +(global-set-key "\C-cl" 'org-store-link) +(global-set-key "\C-ca" 'org-agenda) +(global-set-key "\C-cb" 'org-iswitchb) + +;; Startup folding mode +(setq org-startup-folded "showall") +;; si può definire per-file +;; #+STARTUP: fold +;; #+STARTUP: nofold +;; #+STARTUP: content +;; #+STARTUP: showeverything + +;; Segui i link con tasto RET +(setq org-return-follows-link t) + +; Quali sono i file che Agenda deve considerare quando cerca i TODO +(setq org-agenda-files (list "~/org/inbox.org" + "~/org/memo.org" + "~/org/work.org" + "~/org/gatta.org" + "~/org/moto.org" + "~/org/idee.org" + "~/org/spesa.org" + "~/org/someday.org")) + +;(setq org-agenda-custom-commands +; '(("w" todo "WAIT" nil) +; ("n" todo "NEXT" nil) +; ("d" "Agenda + Next Actions" ((agenda) (todo "NEXT")))) +; ) + +;; Colora i TODO +;(setq org-todo-keywords +; (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") +; (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")))) + +; (setq org-todo-keyword-faces +; (quote (("TODO" :foreground "red" :weight bold) +; ("NEXT" :foreground "forest green" :weight bold) +; ("DONE" :foreground "forest green" :weight bold)))) +; ("WAIT" :foreground "blue" :weight bold) +; ("HOLD" :foreground "magenta" :weight bold) +; ("CANCELLED" :foreground "forest green" :weight bold) +; ("MEETING" :foreground "forest green" :weight bold) +; ("PHONE" :foreground "forest green" :weight bold)))) +;; avail: orange, magenta, red, forest green, blue, + +;;;;;;;;;;;;;;; +;; POST MODE ;; +;;;;;;;;;;;;;;; + +;; carica il modulo post +(require 'post) + +;; Usenet RFC 1855 stipulates we limit email 72 char per line +(add-hook 'post-mode-hook '(lambda () (setq fill-column 72))) + +;; post.el removes the signatures that are cited by default +;; but certain people write their prose below the '--' line. +(setq post-kill-quoted-sig nil) + +;; una chiave, visto che lo devo lanciare manualmente ogni volta +;(global-set-key "\e\e\p" 'post-mode) + +;;;;;;;;;;;;;;; +;; Bookmarks ;; +;;;;;;;;;;;;;;; + +;; shortcut: C-x a e (expand-abbrev) and RET +;(defun bookmark-to-abbrevs () +; "Create abbrevs based on `bookmark-alist'." +; (dolist (bookmark bookmark-alist) +; (let* ((name (car bookmark)) +; (file (bookmark-get-filename name))) +; (define-abbrev global-abbrev-table name file)))) + +;;;;;;;;;;;;;;;;;; +;;; Easy PG mode ;; +;;;;;;;;;;;;;;;;;;; + +;; Easy PG is enabled by default +;; uso: emacs file.gpg +;(require 'epa-file) +;(epa-file-enable) + +;; No GTK popup ma chiedi la password in cline +;; potresti anche settarlo globalmente in gpg conf +;(setenv (concat "GPG_AGENT_INFO" nil)) + +;;;;;;;;;;;;;; +;; ALTRI EL ;; +;;;;;;;;;;;;;; + +;; alcuni sono byte-compiled .elc +;; altri vengono chiamati con load o autoload + +;; Boxes (boxes -l per listare tutti i tipi) +(require 'boxes) +(autoload 'boxes-command-on-region "boxes" nil t) +(autoload 'boxes-remove "boxes" nil t) +(autoload 'boxes-create "boxes" nil t) +(global-set-key "\C-cq" 'boxes-create) +(global-set-key "\C-cr" 'boxes-remove) +(global-set-key "\C-cp" 'boxes-command-on-region) + +;; figlet +(load "figlet.el") + +;; Screenplay mode +;; scene headings; action blocks; dialog blocks +;; TAB RET - TAB TAB RET - TAB TAB TAB RET +(require 'screenplay) +(add-to-list 'auto-mode-alist '("\\.sp\\'" . screenplay-mode)) +(add-to-list 'auto-mode-alist '("\\.screenplay\\'" . screenplay-mode)) + +;; Fountain +(require 'fountain-mode) +(add-to-list 'auto-mode-alist '("\\.fountain\\'" . screenplay-mode)) + +(require 'olivetti) + +(require 'imenu-list) +; (require 'imenu) +; (require 'cl-lib) + +;; Chordpro-mode +(setq auto-mode-alist (cons '("\\.crd$" . chordpro-mode) auto-mode-alist)) +(autoload 'chordpro-mode "chordpro-mode") + +;; Esportare pagine html +;(require 'htmlize) + +;; le bolle col pensierino +;(require 'thinks) + +;; u-mandelbrot +;(autoload 'u-mandelbrot "u-mandelbrot" "A simple fractal browser" t) + +;; dei bellissimi elenchi +;(require 'gse-number-rect) +;; la sua chiave privata +;(global-set-key "\e\e\n" 'gse-number-rectangle) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Attribuire un mode a un file ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Inserendo questa riga all'inizio del file +;; #-*- mode: markdown -*- +;; o anche +;; #-*- shell-script -*- + +;; o anche Nominandolo da qui +(add-to-list 'auto-mode-alist '("\\.screenrc\\'" . shell-script-mode)) +(add-to-list 'auto-mode-alist '("\\.nanorc\\'" . shell-script-mode)) +(add-to-list 'auto-mode-alist '("\\.bash_alias\\'" . shell-script-mode)) + +;;;;;;;;;;;;;;;;;;;;;;; +;; SPELLING - ISPELL ;; +;;;;;;;;;;;;;;;;;;;;;;; + +;(global-set-key "\C-cb" 'ispell-buffer) +;(global-set-key "\C-cr" 'ispell-region) no che la usa orgmode +;(global-set-key "\C-cw" 'ispell-word) +;(setq ispell-dictionary "italian") + +;(setq sgml-mode-hook +;'(lambda () "Defaut per SGML mode." +;(setq ispell-personal-dictionary "/.ispell_mine") +;(ispell-change-dictionary "italian") +;)) + +;(autoload 'ispell-word "ispell" +; "Check the spelling of word in buffer." t) +; (global-set-key "\e$" 'ispell-word) +; (autoload 'ispell-region "ispell" +; "Check the spelling of region." t) +; (autoload 'ispell-buffer "ispell" +; "Check the spelling of buffer." t) +; (autoload 'ispell-complete-word "ispell" +; "Look up current word in dictionary and try to complete it." t) +; (autoload 'ispell-change-dictionary "ispell" +; "Change ispell dictionary." t) +; (autoload 'ispell-message "ispell" +; "Check spelling of mail message or news post.") +; (autoload 'ispell-minor-mode "ispell" +; "Toggle mode to automatically spell check words as they are typed in.") + +;; Aggiungi queste righe alla fine di un documento +;; per definire la lingua del dizionario +;; +;; + +;;;;;;;;;;;;;;;;;; +;; INSERT STUFF ;; +;;;;;;;;;;;;;;;;;; + +;; Time-Stamps: If a "Time-stamp: <>" exist in the first 10 lines of the file +;; emacs will write time-stamp information there when saving the file. +(setq + time-stamp-active t ; do enable time-stamps + time-stamp-line-limit 10 ; check the first 10 lines + time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") +(add-hook 'write-file-hooks 'time-stamp) + +(setq user-full-name "dan") +(setq user-mail-address "dan[at]autistici[dot]org") +;(setq current-language-environment "English") + +(defun insert-name-and-email() + (interactive) + (insert (concat user-full-name " <" user-mail-address ">"))) + +;; F9 inserisce nome e email +(global-set-key [f9] 'insert-name-and-email) + +;; F5 chiama il bookmark file +(global-set-key [f5] 'bookmark-bmenu-list) + +;; Insert euro symbol € con M-x euro +(fset 'euro + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([24 56 return 35 120 50 48 65 67 return] 0 "%d")) arg))) + +;; Inserisci una rosa +(setq rosa-header +"@}-,--- ") + +(defun insert-rosa-header () + "Insert rosa at point." + (interactive) + (let ((mark (point))) + (insert rosa-header) + (comment-region mark (+ mark (length rosa-header))))) + +;; Inserisci il kudos +(setq kudos-header +" + Commenti? Kudos? Consigli? Vaffa? Grazie! +") + +(defun insert-kudos-header () + "Insert kudos at point." + (interactive) + (let ((mark (point))) + (insert kudos-header) + (comment-region mark (+ mark (length kudos-header))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; KeyBindings personali ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; disattiva una chiave, nell'es: ESC e C-u +;(global-unset-key "\e\C-u") + +;; set-justification-full: justifica a destra con spaziatura regolare +;; ESC-ESC-j set-justification-full (right, left, center, none) +(global-set-key "\e\e\j" 'set-justification-full) + +;; string-insert-rectangle: add a prefix char all'inizio di ogni riga in region C-x r t +(global-set-key "\e\e\i" 'string-insert-rectangle) + +;; close-rectangle: deleta spazi a inizio riga in region +(global-set-key "\e\e\d" 'close-rectangle) + +;; kill-rectangle (deleta n char a inizio riga in regione) +;; (evidenzia regione, poi mettiti al n char che vuoi cancellare) C-x r k +(global-set-key "\e\e\k" 'kill-rectangle) + +;;;;;;;;;;;;; +;; ACCENTI ;; +;;;;;;;;;;;;; + +;; per le accentate +;(standard-display-european 1) + +;; attivazione all'avvio del mode-accentate. not. +;(add-hook 'text-mode-hook 'iso-accents-mode) + +;; toggle accents mode in emacs +;(global-set-key "\e\e\w" 'iso-accents-mode) +;(iso-accents-mode non-nil) +;(iso-accents-mode t) +;(add-hook 'iso-acc 'iso-accents-mode)