Skip to content

Commit 82e7f65

Browse files
committed
Merge pull request #117 from sviridov/emacs-24.3-patch
Fixed: emacs 24.3 tests
2 parents 45a006f + 466d00c commit 82e7f65

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

elixir-smie.el

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,45 @@
22

33
(require 'smie)
44

5+
;; HACK: Patch for Emacs 24.3 smie that fix
6+
;; https://github.com/elixir-lang/emacs-elixir/issues/107.
7+
;;
8+
;; defadvice is used to change the behavior only for elixir-mode.
9+
;; Definition of advice is a definition of corresponding function
10+
;; in Emacs 24.4.
11+
(when (and (= 24 emacs-major-version)
12+
(= 3 emacs-minor-version))
13+
(defadvice smie-rule-parent (around elixir-mode-patch activate)
14+
(if (not (eq major-mode 'elixir-mode))
15+
(progn ad-do-it)
16+
(setq ad-return-value
17+
(save-excursion
18+
(goto-char (cadr (smie-indent--parent)))
19+
(cons 'column
20+
(+ (or offset 0)
21+
(smie-indent-virtual)))))))
22+
23+
(defadvice smie-indent-comment (around elixir-mode-patch activate)
24+
(if (not (eq major-mode 'elixir-mode))
25+
(progn ad-do-it)
26+
(setq ad-return-value
27+
(and (smie-indent--bolp)
28+
(let ((pos (point)))
29+
(save-excursion
30+
(beginning-of-line)
31+
(and (re-search-forward comment-start-skip (line-end-position) t)
32+
(eq pos (or (match-end 1) (match-beginning 0))))))
33+
(save-excursion
34+
(forward-comment (point-max))
35+
(skip-chars-forward " \t\r\n")
36+
(unless
37+
(save-excursion
38+
(let ((next (funcall smie-forward-token-function)))
39+
(or (if (zerop (length next))
40+
(or (eobp) (eq (car (syntax-after (point))) 5)))
41+
(rassoc next smie-closer-alist))))
42+
(smie-indent-calculate))))))))
43+
544
;; FIXME: This is me being lazy. CL is a compile-time dep only.
645
;; (But for now, there is no real file-compilation plot, so let's
746
;; scrape by with the runtime dep.)

0 commit comments

Comments
 (0)