emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 5043a96 38/63: Correctly wrap auto-fill-function when it's


From: Noam Postavsky
Subject: [elpa] master 5043a96 38/63: Correctly wrap auto-fill-function when it's toggled on later
Date: Mon, 17 Jul 2017 22:54:16 -0400 (EDT)

branch: master
commit 5043a961215158619199cf03a85a0c063a28c644
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Correctly wrap auto-fill-function when it's toggled on later
    
    * yasnippet.el (yas--auto-fill-wrapper): New function, extracted from
    `yas-minor-mode'.
    (yas-minor-mode): Call it, and it to `auto-fill-mode-hook'.
---
 yasnippet.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/yasnippet.el b/yasnippet.el
index 7f541e8..47b8ff5 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -768,6 +768,12 @@ which decides on the snippet to expand.")
 (defvar yas-minor-mode-hook nil
   "Hook run when `yas-minor-mode' is turned on.")
 
+(defun yas--auto-fill-wrapper ()
+  (when (and auto-fill-function
+             (not (eq auto-fill-function #'yas--auto-fill)))
+    (setq yas--original-auto-fill-function auto-fill-function)
+    (setq auto-fill-function #'yas--auto-fill)))
+
 ;;;###autoload
 (define-minor-mode yas-minor-mode
   "Toggle YASnippet mode.
@@ -802,14 +808,13 @@ Key bindings:
          ;; Perform JIT loads
          (yas--load-pending-jits)
          ;; Install auto-fill handler.
-         (when (and auto-fill-function
-                    (not (eq auto-fill-function #'yas--auto-fill)))
-           (setq yas--original-auto-fill-function auto-fill-function)
-           (setq auto-fill-function #'yas--auto-fill)))
+         (yas--auto-fill-wrapper)       ; Now...
+         (add-hook 'auto-fill-mode-hook #'yas--auto-fill-wrapper)) ; or later.
         (t
          ;; Uninstall the direct keymaps, post-command hook, and
          ;; auto-fill handler.
          (remove-hook 'post-command-hook #'yas--post-command-handler t)
+         (remove-hook 'auto-fill-mode-hook #'yas--auto-fill-wrapper)
          (when (local-variable-p 'yas--original-auto-fill-function)
            (setq auto-fill-function yas--original-auto-fill-function))
          (setq emulation-mode-map-alists



reply via email to

[Prev in Thread] Current Thread [Next in Thread]