Disable insertion of spaces in a #include line.

Pascal J. Bourguignon [2018-10-22 07:55]
Disable insertion of spaces in a #include line.
Filename
freerdp-c-style.el
diff --git a/freerdp-c-style.el b/freerdp-c-style.el
index 7956384..9767445 100644
--- a/freerdp-c-style.el
+++ b/freerdp-c-style.el
@@ -449,15 +449,18 @@

 (defun freerdp-electric-space-before-after-double (repeat)
   (interactive "p")
-  (let ((ch (this-command-keys)))
+  (let ((ch      (this-command-keys))
+        (include nil))
    (if (and (= 1 repeat) (stringp ch) (= 1 (length ch)))
        (progn
          (freerdp-remove-previous-spaces)
+         (setf include (looking-back "^#[ \t]*include" (save-excursion (beginning-of-line) (point))))
          (when (or (/= (aref ch 0) (char-before))
                    (=  (aref ch 0) (char-before (1- (point)))))
            (insert " "))
          (self-insert-command 1)
-         (insert " "))
+         (unless include
+           (insert " ")))
        (self-insert-command repeat))))

 (defun freerdp-electric-space-before-after-= (repeat)
ViewGit