Update.
[elisp.git] / vm
diff --git a/vm b/vm
index 57aea1f..49104ac 100644 (file)
--- a/vm
+++ b/vm
 
 ;; Store and restore the window configuration
 
+(setq ff/window-configuration-before-vm nil)
+
 (defadvice vm (before ff/store-window-configuration nil activate)
-  (unless (boundp 'ff/window-configuration-before-vm)
+  (unless ff/window-configuration-before-vm
     (setq ff/window-configuration-before-vm (current-window-configuration)))
   )
 
 (defadvice vm-quit (after ff/restore-window-configuration nil activate)
-  (when (boundp 'ff/window-configuration-before-vm)
+  (when ff/window-configuration-before-vm
     (set-window-configuration ff/window-configuration-before-vm)
-    (makunbound 'ff/window-configuration-before-vm)
+    (setq ff/window-configuration-before-vm nil)
     )
   )
 
@@ -327,36 +329,32 @@ attachement from mail."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Activate the required modes and authorize the commenting
 
+(defun ff/does-not-fill (&optional a b) (interactive) (message "Nope"))
+
 (defun ff/prepare-mail-mode ()
   (bbdb-define-all-aliases)
   (flyspell-mode)
-  (auto-fill-mode)
   (mail-abbrevs-setup)
   (yas/minor-mode)
 
-  ;; (setq fill-paragraph-function 'mail-mode-fill-paragraph)
+  ;; Let's try the visual-line mode for mails
 
-  ;; Since I set the comment prefix, I have to tell the filling
-  ;; functions not to use it
+  (auto-fill-mode)
+  ;; (setq fill-paragraph-function 'ff/does-not-fill)
+  ;; (visual-line-mode)
 
-  ;; ******************* removed Aug 23
-  ;; (setq fill-paragraph-handle-comment nil)
-  ;; ;; (when message-yank-prefix
   (set (make-local-variable 'comment-start) vm-included-text-prefix)
-  ;; (set (make-local-variable 'comment-start-skip)
-  ;; (concat "^\\(" (regexp-quote vm-included-text-prefix) "\\)"))
-  ;; ;; )
   )
 
 (add-hook 'mail-mode-hook 'ff/prepare-mail-mode)
-;; (add-hook 'mail-mode-hook 'orgtbl-mode)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; To have a slightly darker background for headers
 
 (ff/configure-faces
  ;; '((ff/mail-header-face :background "#c8c8ff"))
- '((ff/mail-header-face :background "#f0f0f0"))
+ '((ff/mail-header-face :background "#eaf0ff"))
+ ;; '((ff/mail-header-face :background "#fff0a0"))
  ;; '((ff/mail-header-face :foreground "blue4"))
  )
 
@@ -522,7 +520,6 @@ an attachment")
       )
     s))
 
-
 ;; You can not have a line starting with "From:" in a pure text
 ;; mail. The smtp server would add a leading character to prevent it.
 
@@ -593,11 +590,14 @@ an attachment")
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; If we can, encrypt!
 
-(add-hook 'vm-mode-hook 'mc-install-read-mode)
-(add-hook 'vm-summary-mode-hook 'mc-install-read-mode)
-(add-hook 'vm-virtual-mode-hook 'mc-install-read-mode)
-(add-hook 'vm-mail-mode-hook 'mc-install-write-mode)
-(add-hook 'vm-presentation-mode-hook 'mc-install-read-mode)
+;; (autoload 'mc-install-write-mode "mailcrypt" nil t)
+;; (autoload 'mc-install-read-mode "mailcrypt" nil t)
+
+;; (add-hook 'vm-mode-hook 'mc-install-read-mode)
+;; (add-hook 'vm-summary-mode-hook 'mc-install-read-mode)
+;; (add-hook 'vm-virtual-mode-hook 'mc-install-read-mode)
+;; (add-hook 'vm-mail-mode-hook 'mc-install-write-mode)
+;; (add-hook 'vm-presentation-mode-hook 'mc-install-read-mode)
 
 ;; (defun ff/encrypt-mail-if-possible () (interactive)
 ;; (condition-case nil (mc-encrypt-message)
@@ -642,6 +642,19 @@ an attachment")
 ;; (define-key vm-mail-mode-map [(shift iso-lefttab)] 'mail-mode-smart-tab)
 (define-key vm-mail-mode-map [(shift iso-lefttab)] 'bbdb-complete-name)
 
+(defun ff/kill-to-signature () (interactive)
+       (save-excursion
+         (delete-region
+          (point)
+          (progn
+            (search-forward-regexp "^-- *$")
+            (- (match-beginning 0) 1))
+          )
+         )
+       )
+
+(define-key vm-mail-mode-map [(control c) (k)] 'ff/kill-to-signature)
+
 ;; The definition of "\t" is forced through a hook defined in
 ;; vm-init.el, so I add mine. This is ugly.
 
@@ -659,18 +672,21 @@ an attachment")
 
 (defun ff/first-buffer-in-mode (l m)
   (if l
-      (if (eq (save-excursion
-                (set-buffer (car l)) major-mode) m)
+      (if (eq
+           ;; (save-excursion (set-buffer (car l)) major-mode)
+           (with-current-buffer (car l) major-mode)
+           m)
           (car l)
         (ff/first-buffer-in-mode (cdr l) m))))
 
 (defun ff/compose-mail (&optional force-new)
-  "Cycles through an existing buffers with major mode `mail-mode',
+  "Cycles through existing buffers with major mode `mail-mode',
 or invoke `vm-compose-mail' if none can be found or if FORCE-NEW
 is t."
   (interactive "P")
   (when (eq major-mode 'mail-mode) (bury-buffer))
   (let ((buf (and (not force-new)
+                  ;; (not (eq major-mode 'mail-mode))
                   (ff/first-buffer-in-mode (buffer-list) 'mail-mode))))
     (if buf (switch-to-buffer buf)
       (vm-compose-mail))))
@@ -681,7 +697,7 @@ is t."
 ;; bbdb
 
 (load "bbdb")
-(load "bbdb-hooks")
+;; (load "bbdb-hooks")
 
 (when (load "bbdb-vm" t)
 
@@ -718,12 +734,26 @@ instance, someone in bbdb named \"Paul Smith\" would generate an alias
     (let ((link "/tmp/at")
           (dir (format-time-string "/tmp/at-%Y%m%d-%H%M%S" (current-time))))
       (mkdir dir)
-      (when (file-symlink-p link) (delete-file link))
-      (unless (file-exists-p link) (make-symbolic-link dir link 1))
-      (vm-pipe-message-to-command (concat "munpack -C " dir))
+
+      (when (file-symlink-p (concat link "~~"))
+        (delete-file (concat link "~~")))
+
+      (when (and (file-symlink-p (concat link "~"))
+                 (not (file-exists-p (concat link "~~"))))
+        (rename-file (concat link "~") (concat link "~~")))
+
+      (when (and (file-symlink-p link)
+                 (not (file-exists-p (concat link "~"))))
+        (file-symlink-p link) (rename-file link (concat link "~")))
+
+      (unless (file-exists-p link)
+        (make-symbolic-link dir link 1))
+
+      ;; (vm-pipe-message-to-command (concat "munpack -C " dir))
+
+      (vm-pipe-message-to-command (concat "munpack -t -C " dir))
       (message "Wrote files to %s" dir)
       )
-
     )
   )
 
@@ -821,3 +851,21 @@ created."
       (message "No attachments to be saved!"))))
 
 (define-key vm-summary-mode-map [(control c) (control s)] 'ff/vm-mime-save-all-attachments)
+
+;; I do not like relief
+
+(ff/configure-faces
+ '(
+
+   ;; (vm-highlight-url :weight 'bold :foreground "#0000f0" :box nil)
+   (vm-highlight-url :underline nil :foreground "#0000f0" :box nil)
+   ;; (vm-highlight-url :background "white" :foreground "#0000f0" :box nil)
+   (vm-highlighted-header :box nil) ;; :weight 'bold :background "white")
+
+   (vm-attachment-button :background "#f0d0d0" :box nil)
+   (vm-attachment-button-mouse :background "#f0d0d0" :box nil)
+   (vm-attachment-button-pressed-face :background "#f0d0d0" :box nil)
+   (vm-mime-button :background "#f0d0d0" :box nil)
+   (vm-mime-button-mouse :background "#f0d0d0" :box nil)
+   (vm-mime-button-pressed-face :background "#f0d0d0" :box nil)
+   ))