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

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

[elpa] 01/14: Set company-added-newline to t if the buffer was modified


From: Dmitry Gutov
Subject: [elpa] 01/14: Set company-added-newline to t if the buffer was modified
Date: Tue, 18 Feb 2014 05:51:00 +0000

dgutov pushed a commit to branch master
in repository elpa.

commit 9f465f9918f531777f4aaf099411fa8166947bc4
Author: Dmitry Gutov <address@hidden>
Date:   Thu Feb 6 07:03:26 2014 +0200

    Set company-added-newline to t if the buffer was modified
    
    Fixes #58
---
 company.el |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/company.el b/company.el
index c2df4cf..0b7ab89 100644
--- a/company.el
+++ b/company.el
@@ -1177,9 +1177,11 @@ Keywords and function definition names are ignored."
   (or (and company-candidates (company--continue))
       (and (company--should-complete) (company--begin-new)))
   (when company-candidates
-    (when (and company-end-of-buffer-workaround (eobp))
-      (save-excursion (insert "\n"))
-      (setq company-added-newline (buffer-chars-modified-tick)))
+    (let ((modified (buffer-modified-p)))
+      (when (and company-end-of-buffer-workaround (eobp))
+        (save-excursion (insert "\n"))
+        (setq company-added-newline
+              (or modified (buffer-chars-modified-tick)))))
     (setq company-point (point)
           company--point-max (point-max))
     (company-ensure-emulation-alist)
@@ -1192,7 +1194,8 @@ Keywords and function definition names are ignored."
        (let ((tick (buffer-chars-modified-tick)))
          (delete-region (1- (point-max)) (point-max))
          (equal tick company-added-newline))
-       ;; Only set unmodified when tick remained the same since insert.
+       ;; Only set unmodified when tick remained the same since insert,
+       ;; and the buffer wasn't modified before.
        (set-buffer-modified-p nil))
   (when company-prefix
     (if (stringp result)



reply via email to

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