Skip to content

Commit

Permalink
Fix byte-compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xwl committed Feb 11, 2020
1 parent 0267e94 commit 5c71694
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
38 changes: 19 additions & 19 deletions electric-spacing-cc-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
(add-hook 'c-mode-common-hook 'electric-spacing-cc-mode-hook)

(defun electric-spacing-cc-mode-: ()
(cond ((looking-back ": *")
(cond ((looking-back ": *" nil)
(search-backward ":" (line-beginning-position) t 1)
(replace-match "::"))
((save-excursion
Expand All @@ -58,18 +58,18 @@
;; | printf("%d", *ip);
;; | func(*p);
;; `----
(cond ((looking-back (concat (electric-spacing-c-types) " *" ))
(cond ((looking-back (concat (electric-spacing-c-types) " *") nil)
(electric-spacing-insert "*" 'before))
((looking-back "\\* *")
((looking-back "\\* *" nil)
(electric-spacing-insert "*" 'middle))
((looking-back "^[ (]*")
((looking-back "^[ (]*" nil)
(electric-spacing-insert "*" 'middle)
(indent-according-to-mode))
((looking-back "( *")
((looking-back "( *" nil)
(electric-spacing-insert "*" 'middle))
((looking-back ", *")
((looking-back ", *" nil)
(electric-spacing-insert "*" 'before))
((looking-back "= *")
((looking-back "= *" nil)
(electric-spacing-insert "*" 'before))
(t
(electric-spacing-insert "*"))))
Expand All @@ -85,27 +85,27 @@
;; | scanf ("%d", &i);
;; | func(&i)
;; `----
(cond ((looking-back (concat (electric-spacing-c-types) " *" ))
(cond ((looking-back (concat (electric-spacing-c-types) " *") nil)
(electric-spacing-insert "&" 'after))
((looking-back "= *")
((looking-back "= *" nil)
(electric-spacing-insert "&" 'before))
((looking-back "( *")
((looking-back "( *" nil)
(electric-spacing-insert "&" 'middle))
((looking-back ", *")
((looking-back ", *" nil)
(electric-spacing-insert "&" 'before))
(t
(electric-spacing-insert "&" 'middle))))

(defun electric-spacing-cc-mode-< ()
"See `electric-spacing-insert'."
(cond ((looking-back "operator<?")
(cond ((looking-back "operator<?" nil)
(insert "<"))
(t
(electric-spacing-insert "<"))))

(defun electric-spacing-cc-mode-> ()
"See `electric-spacing-insert'."
(cond ((looking-back " - ")
(cond ((looking-back " - " nil)
(delete-char -3)
(insert "->"))
((electric-spacing-cc-mode-include-line)
Expand All @@ -120,8 +120,8 @@

(defun electric-spacing-cc-mode-+ ()
"See `electric-spacing-insert'."
(cond ((looking-back "\\+ *")
(when (looking-back "[a-zA-Z0-9_] +\\+ *")
(cond ((looking-back "\\+ *" nil)
(when (looking-back "[a-zA-Z0-9_] +\\+ *" nil)
(save-excursion
(backward-char 2)
(delete-horizontal-space)))
Expand All @@ -132,9 +132,9 @@

(defun electric-spacing-cc-mode-- ()
"See `electric-spacing-insert'."
(cond ((looking-back "\\- *")
(cond ((looking-back "\\- *" nil)
(electric-spacing-insert "-" 'middle))
((looking-back (concat electric-spacing-operators-regexp " *"))
((looking-back (concat electric-spacing-operators-regexp " *") nil)
(insert "-"))
(t
(electric-spacing-insert "-"))))
Expand All @@ -149,8 +149,8 @@
;; | a % b;
;; | printf("%d %d\n", a % b);
;; `----
(if (and (looking-back "\".*")
(not (looking-back "\",.*")))
(if (and (looking-back "\".*" nil)
(not (looking-back "\",.*" nil)))
(insert "%")
(electric-spacing-insert "%")))

Expand Down
6 changes: 3 additions & 3 deletions electric-spacing-python-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(require 'electric-spacing)

(defun electric-spacing-python-mode-: ()
(if (and (not (in-string-p))
(if (and (not (nth 3 (syntax-ppss))) ; not in string
(eq (electric-spacing-enclosing-paren) ?\{))
(electric-spacing-insert ":" 'after)
(insert ":")))
Expand All @@ -35,9 +35,9 @@
;; Can only occur after '(' ',' or on a new line, so just check
;; for those. If it's just after a comma then also insert a space
;; before the *.
(cond ((looking-back ",")
(cond ((looking-back "," nil)
(insert " *"))
((looking-back "[(,^)][ \t]*[*]?")
((looking-back "[(,^)][ \t]*[*]?" nil)
(insert "*"))
;; Othewise act as normal
(t
Expand Down
4 changes: 2 additions & 2 deletions electric-spacing-rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(require 'electric-spacing)

(defun electric-spacing-rust-mode-: ()
(if (looking-back ": *")
(if (looking-back ": *" nil)
(progn
(search-backward " :" (line-beginning-position) t 1)
(replace-match "::"))
Expand All @@ -38,7 +38,7 @@
(defalias 'electric-spacing-rust-mode-.-rustic-mode 'electric-spacing-.)

(defun electric-spacing-rust-mode-& ()
(if (looking-back "( *")
(if (looking-back "( *" nil)
(electric-spacing-insert "&" 'middle)
(electric-spacing-insert "&" 'before)))

Expand Down
26 changes: 13 additions & 13 deletions electric-spacing.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ so let's not get too insert-happy."
(cond ((derived-mode-p 'emacs-lisp-mode)
;; Do nothing in Emacs lisp mode
(insert "("))
((looking-back "[,;] *")
((looking-back "[,;] *" nil)
(electric-spacing-insert "(" 'before))
((looking-back "[({!~] *")
((looking-back "[({!~] *" nil)
(electric-spacing-insert "(" 'middle))
((or electric-spacing-parens
(and electric-spacing-control-statement-parens
Expand All @@ -255,17 +255,17 @@ so let's not get too insert-happy."
(electric-spacing-document?))
(electric-spacing-insert "." 'after)
(insert " "))
((or (looking-back "[0-9]")
((or (looking-back "[0-9]" nil)
(or (and
(derived-mode-p 'python-mode 'ruby-mode)
(looking-back "[a-z\)]"))
(looking-back "[a-z\)]" nil))
(and
(derived-mode-p 'js-mode 'js2-mode)
(looking-back "[a-z\)$]"))))
(looking-back "[a-z\)$]" nil))))
(insert "."))
((derived-mode-p 'cperl-mode 'perl-mode 'ruby-mode)
;; Check for the .. range operator
(if (looking-back ".")
(if (looking-back "." nil)
(insert ".")
(insert " . ")))
(t
Expand All @@ -274,11 +274,11 @@ so let's not get too insert-happy."
(defun electric-spacing-+ ()
"See `electric-spacing-insert'."
(cond ;; func(++i);
((looking-back "( *")
((looking-back "( *" nil)
(electric-spacing-insert "+" 'middle))

;; j = ++i;
((looking-back "= *")
((looking-back "= *" nil)
(electric-spacing-insert "+" 'before))

(t
Expand All @@ -287,16 +287,16 @@ so let's not get too insert-happy."
(defun electric-spacing-- ()
"See `electric-spacing-insert'."
(cond ;; exponent notation, e.g. 1e-10: don't space
((looking-back "[0-9.]+[eE]")
((looking-back "[0-9.]+[eE]" nil)
(insert "-"))

;; a = -9
((and (looking-back (concat electric-spacing-operators-regexp " *"))
(not (looking-back "- *")))
((and (looking-back (concat electric-spacing-operators-regexp " *") nil)
(not (looking-back "- *" nil)))
(electric-spacing-insert "-" 'before))

;; func(--i)
((looking-back "( *")
((looking-back "( *" nil)
(electric-spacing-insert "-" 'middle))

(t
Expand All @@ -310,7 +310,7 @@ so let's not get too insert-happy."
"See `electric-spacing-insert'."
;; First class regex operator =~ langs
(cond ((derived-mode-p 'ruby-mode 'perl-mode 'cperl-mode)
(if (looking-back "= ")
(if (looking-back "= " nil)
(progn
(delete-char -2)
(insert "=~ "))
Expand Down

0 comments on commit 5c71694

Please sign in to comment.