;-- El archivo .emacs de SeaJob
;-- Basado en el de David Dorward (lo puedes conseguir en dotfiles.com)
;-- Diseñado para GNU Emacs 20.7 en un sistemna Debian GNU/Linux 
;-- Corregido para Emacs21, y con el nuevo soporte para mailcrypt

;--No menus at command line
;    (if (equal window-system nil)
;    (menu-bar-mode nil))
;
;--CORREO
;
;--Precargamos el vm (pendiente de revisión)
    (autoload 'vm "vm" "Arraca VM en tu buzón primario" t)
    (autoload 'vm-other-frame "vm" "Como `vm'pero arranca en otra ventana" t)
    (autoload 'vm-visit-folder "vm" "Arranca VM en un buzón aleatorio" t)
    (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
    (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
    (autoload 'vm-mail "vm" "Send a mail message using VM." t)
    (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)

;--Hacemos que el mail salga como seajob@sindominio.net
;(custom-set-variables '(mail-host-address "sindominio.net")
;		      '(mail-from-style (quote angles))
;		      '(user-mail-address "seajob@sindominio.net"))

;--Ponemos un mayor delante del texto al que respondemos
;(setq mail-yank-prefix ">")

;--Guardamos todo el mail que enviamos en un fichero
;--Es buena idea ir rotándolo; de momento no sé cómo hacerlo
;(setq mail-archive-file-name "~/mail/sent-items")

;--Añadir automaticamente ~/.firma al final de todos mis mails
;(setq mail-signature t)

;--Usamos abreviaturas en (Resent-)?(To|Cc|Bcc):
;(add-hook 'mail-setup-hook 'mail-abbrevs-setup)

;--Cargamos un address book
;(load-file "~/.dires")

;--Para eliminar los mensajes borrados automáticamente
; No funciona, habrá que revisarlo...
;(add-hook 'vm-mode-hook
;          '(lambda ()
;             (local-set-key "Q" 'vm-quit)
;             (local-set-key "q" "#Q")))

;-- Recomendado (aunque no termino de entender qué hace)
(cond (window-system
       (setq hilit-mode-enable-list  '(not text-mode)
	     hilit-background-mode   'light
	     hilit-inhibit-hooks     nil
	     hilit-inhibit-rebinding nil)
       (require 'hilit19)
       (add-hook 'vm-summary-pointer-update-hook 'hilit-rehighlight-buffer)
       (add-hook 'vm-select-message-hook 'hilit-rehighlight-buffer)
       (hilit-translate comment 'firebrick-bold)
       (hilit-set-mode-patterns
	'outline-mode
	'(("^\*.*$" nil defun)
	  ))
       ))

;--Cosas del mailcrypt+GNUpg
;- Le decimos a mailcrypt que use GnuPG (PGP sucks!)
(load-library "mailcrypt") ; provides "mc-setversion"
(mc-setversion "gpg")

;--FIN DE CORREO

;--Support for compressed files
    (require 'jka-compr)

;--Load Template support
;    (require 'template)
;    (template-initialize)

;--Use Windoze style selection, [del], [home], [end], 
(custom-set-variables '(pc-selection-mode t nil (pc-select)))

(custom-set-faces)


;-- MINIBUFFER & THINGS TO DISPLAY

;--Show the time in the minibuffer 
    (display-time) 

;--Turn on the column numbering in the minibuffer 
    (column-number-mode 1) 

;--Replace yes/no+enter prompts with y/n prompts
    (fset 'yes-or-no-p 'y-or-n-p) 

;--Disable the menu-bar in console mode for a little more screen space. You can still use F10 to access it in the minibuffer
    (menu-bar-mode (if window-system 1 -1)) 

;--Format the title-bar to always include the buffer name
     (setq frame-title-format "emacs - %b")

;-- SUBRAYADO Y COLOREADO

;--Marcar los paréntesis emparejados (fundamental para programar)
    (setq show-paren-mode t)
    (setq show-paren-style 'parenthesis)

;--Colorear todo lo posible
    (setq font-lock-maximum-decoration t)

;--Activar el coloreado
    (global-font-lock-mode 1 t)

;-- MISC

;--Provide access to system clipboard
     (setq x-select-enable-clipboard t)

;--Change default major mode to text from fundamental
     (setq default-major-mode 'text-mode)

;--Ddon't automatically add new lines when scrolling down at the bottom of a buffer
     (setq next-line-add-newlines nil)

;--Scroll just one line when hitting the bottom of the window
     (setq scroll-step 1)

;--Word-wrap when editing an email message
     (add-hook 'mail-mode-hook 'turn-on-auto-fill)

;--Use html-helper-mode when editing .html files
     (setq auto-mode-alist (cons '("\\.htm$" . html-helper-mode) auto-mode-alist))
     (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))

;--Allow me to use Lucida Typewriter font
      '(font-menu-ignore-scaled-fonts nil)

;--set From: address used in header of email I send
;      '(user-mail-address "david@dorward.co.uk")

;--Load bbdb
;     (require 'bbdb)
;     (bbdb-initialize)
; ---- language-env DON'T MODIFY THIS LINE!
;-*-emacs-lisp-*-
;;/etc/emacs/site-start.d/50user-es.el
;

;;--- soportar teclado europeo ------------------------------- 
(set-input-mode  (car (current-input-mode))
		 (nth 1 (current-input-mode))
		 0)
(standard-display-european t)

; no usar caracteres no-ascii (como acentos) como final de palabra
(if (>= emacs-major-version 20)
    (set-language-environment "Latin-1")
    (require 'iso-syntax))
(require 'disp-table)

;;--- redefinir algunas teclas ----------------------------------
;(global-set-key [backspace] 'backward-delete-char-untabify)
; la siguiente línea no debería ropmer el caracter de borrado
; en búsquedas incrementales - tiene esto otras desventajas?
(global-set-key "\177" 'backward-delete-char-untabify)
(global-set-key [delete] 'delete-char)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
;(global-set-key [C-home] 'beginning-of-buffer)
;(global-set-key [C-end] 'end-of-buffer)

; Otras varias (gracias a Jose Manuel Moya)
(defvar cursor-map-2 (make-keymap) "for ESC-[")
(fset 'Cursor-Map-2 cursor-map-2)
(define-key esc-map "[" 'Cursor-Map-2)

(define-key esc-map "[A" 'previous-line)
(define-key esc-map "[B" 'next-line)
(define-key esc-map "[C" 'forward-char)
(define-key esc-map "[D" 'backward-char)
(define-key esc-map "[H" 'beginning-of-line)
(define-key esc-map "[Y" 'end-of-line)
(define-key esc-map "[5^" 'scroll-down)
(define-key esc-map "[6^" 'scroll-up)
(define-key esc-map "[[A" 'help-for-help)
(define-key esc-map "[[B" 'byte-compile-file)
(define-key esc-map "[[C" 'isearch-forward)
(define-key esc-map "[[D" 'query-replace-regexp)
(define-key esc-map "[[E" 'eval-defun)
(define-key esc-map "[[F" 'eval-current-buffer)
(define-key esc-map "[[G" 'buffer-menu)
(define-key esc-map "[[H" 'global-set-key)
(define-key esc-map "[[I" 'save-buffer)
(define-key esc-map "[[J" 'save-buffers-kill-emacs)
(define-key esc-map "[2^" 'set-mark-command)
(define-key esc-map "[3^" 'delete-char)

; entradas necesarias para XEmacs:
(global-set-key [(control home)] 'beginning-of-buffer)
(global-set-key [(control end)] 'end-of-buffer)
; ---- language-env end DON'T MODIFY THIS LINE!
; ---- language-env DON'T MODIFY THIS LINE!
;-*-emacs-lisp-*-
;;/etc/emacs/site-start.d/50user-es.el
;

;;--- soportar teclado europeo ------------------------------- 
(set-input-mode  (car (current-input-mode))
		 (nth 1 (current-input-mode))
		 0)
; `standard-display-european' is semi-obsolete and conflicts
; with multibyte characters. `set-language-environment' is
; a substitute.
; (standard-display-european t)

; no usar caracteres no-ascii (como acentos) como final de palabra
(if (>= emacs-major-version 20)
    (set-language-environment "Latin-1")
    (require 'iso-syntax))
(require 'disp-table)

;;--- redefinir algunas teclas ----------------------------------
;(global-set-key [backspace] 'backward-delete-char-untabify)
; la siguiente línea no debería ropmer el caracter de borrado
; en búsquedas incrementales - tiene esto otras desventajas?
(global-set-key "\177" 'backward-delete-char-untabify)
(global-set-key [delete] 'delete-char)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
;(global-set-key [C-home] 'beginning-of-buffer)
;(global-set-key [C-end] 'end-of-buffer)

; Otras varias (gracias a Jose Manuel Moya)
(defvar cursor-map-2 (make-keymap) "for ESC-[")
(fset 'Cursor-Map-2 cursor-map-2)
(define-key esc-map "[" 'Cursor-Map-2)

(define-key esc-map "[A" 'previous-line)
(define-key esc-map "[B" 'next-line)
(define-key esc-map "[C" 'forward-char)
(define-key esc-map "[D" 'backward-char)
(define-key esc-map "[H" 'beginning-of-line)
(define-key esc-map "[Y" 'end-of-line)
(define-key esc-map "[5^" 'scroll-down)
(define-key esc-map "[6^" 'scroll-up)
(define-key esc-map "[[A" 'help-for-help)
(define-key esc-map "[[B" 'byte-compile-file)
(define-key esc-map "[[C" 'isearch-forward)
(define-key esc-map "[[D" 'query-replace-regexp)
(define-key esc-map "[[E" 'eval-defun)
(define-key esc-map "[[F" 'eval-current-buffer)
(define-key esc-map "[[G" 'buffer-menu)
(define-key esc-map "[[H" 'global-set-key)
(define-key esc-map "[[I" 'save-buffer)
(define-key esc-map "[[J" 'save-buffers-kill-emacs)
(define-key esc-map "[2^" 'set-mark-command)
(define-key esc-map "[3^" 'delete-char)

; ---- language-env end DON'T MODIFY THIS LINE!
