* mu4e-compose: disable auto-completion for emacs23 for now

This commit is contained in:
djcb
2012-06-24 09:45:53 +03:00
parent 1d7b7a00ce
commit 43e7a0c5df

View File

@ -73,6 +73,7 @@ replying to messages."
:type 'boolean :type 'boolean
:group 'mu4e-compose) :group 'mu4e-compose)
;; note, "substring" seems to work pretty well, but is not available for emacs23; ;; note, "substring" seems to work pretty well, but is not available for emacs23;
;; so there we use "partial-completion" instead ;; so there we use "partial-completion" instead
(defvar mu4e-compose-completion-styles (defvar mu4e-compose-completion-styles
@ -82,11 +83,9 @@ replying to messages."
"How to do matching for contacts-completion; see "How to do matching for contacts-completion; see
`completion-styles' and `completion-styles-alist'.") `completion-styles' and `completion-styles-alist'.")
(defcustom mu4e-compose-cycle-threshold 5 (defvar mu4e~compose-cycle-threshold 5
"Number of completion matches below which you can cycle through "Number of completion matches below which you can cycle through
them; see `completion-cycle-threshold' (emacs24)." them; see `completion-cycle-threshold' (emacs24).")
:type 'list
:group 'mu4e-compose)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -104,7 +103,6 @@ them; see `completion-cycle-threshold' (emacs24)."
(or (plist-get mu4e-captured-message :subject) "No subject") (or (plist-get mu4e-captured-message :subject) "No subject")
"attachment"))) "attachment")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e~compose-user-agent-construct () (defun mu4e~compose-user-agent-construct ()
@ -456,18 +454,36 @@ needed, set the Fcc header, and register the handler function."
(defconst mu4e~compose-address-fields-regexp (defconst mu4e~compose-address-fields-regexp
"^\\(To\\|B?Cc\\|Reply-To\\|From\\):") "^\\(To\\|B?Cc\\|Reply-To\\|From\\):")
(defun mu4e~compose-find-completion-style (some-style)
"Find completion style SOME-STYLE in completion-styles-alist, or return nil."
(car-safe
(find-if
(lambda (style) (eq some-style (car style))) completion-styles-alist)))
(defun mu4e~compose-setup-completion () (defun mu4e~compose-setup-completion ()
"Set up autocompletion of addresses." "Set up autocompletion of addresses."
(let ((compstyle
(or (mu4e~compose-find-completion-style 'substring)
(mu4e~compose-find-completion-style 'partial-completion))))
;; emacs-24+ has 'substring, otherwise we try partial-completion, otherwise
;; we leave it at the default
(when compstyle
(make-local-variable 'completion-styles)
(setq completion-styles compstyle))
;; completion-cycle-treshold requires emacs-24+
(when (boundp 'completion-cycle-threshold) ;; emacs24 only (when (boundp 'completion-cycle-threshold) ;; emacs24 only
(make-local-variable 'completion-cycle-threshold) (make-local-variable 'completion-cycle-threshold)
completion-cycle-threshold) mu4e-compose-cycle-threshold (setq completion-cycle-threshold mu4e~compose-cycle-threshold))
(make-local-variable 'completion-styles) ;; this is a bit ugly...
(setq completion-styles mu4e-compose-completion-styles) (make-local-variable 'completion-at-point-functions)
(add-to-list 'completion-at-point-functions 'mu4e~compose-complete-contact) (add-to-list 'completion-at-point-functions 'mu4e~compose-complete-contact)
;; this seems to be needed for emacs23: ;; this seems to be needed for emacs23:
(make-local-variable 'message-completion-alist) ;; (when (eq emacs-major-version 23)
(add-to-list 'message-completion-alist ;; (make-local-variable 'message-completion-alist)
mu4e~compose-address-fields-regexp . completion-at-point)) ;; (add-to-list 'message-completion-alist
;; (cons mu4e~compose-address-fields-regexp
;; 'mu4e~compose-complete-contact)))
))
(define-derived-mode mu4e-compose-mode message-mode "mu4e:compose" (define-derived-mode mu4e-compose-mode message-mode "mu4e:compose"
"Major mode for the mu4e message composition, derived from `message-mode'. "Major mode for the mu4e message composition, derived from `message-mode'.
@ -487,8 +503,9 @@ needed, set the Fcc header, and register the handler function."
;; mail files lives in... ;; mail files lives in...
(setq default-directory (expand-file-name "~/")) (setq default-directory (expand-file-name "~/"))
;; offer completion for e-mail addresses ;; offer completion for e-mail addresses, for now only for emacs-24
(when mu4e-compose-complete-addresses (when (and mu4e-compose-complete-addresses
(> emacs-major-version 23))
(mu4e~compose-setup-completion)) (mu4e~compose-setup-completion))
;; setup the fcc-stuff, if needed ;; setup the fcc-stuff, if needed