Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: emacs 24.3 tests #117

Merged
merged 1 commit into from
Sep 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@

(require 'smie)

;; HACK: Patch for Emacs 24.3 smie that fix
;; https://github.com/elixir-lang/emacs-elixir/issues/107.
;;
;; defadvice is used to change the behavior only for elixir-mode.
;; Definition of advice is a definition of corresponding function
;; in Emacs 24.4.
(when (and (= 24 emacs-major-version)
(= 3 emacs-minor-version))
(defadvice smie-rule-parent (around elixir-mode-patch activate)
(if (not (eq major-mode 'elixir-mode))
(progn ad-do-it)
(setq ad-return-value
(save-excursion
(goto-char (cadr (smie-indent--parent)))
(cons 'column
(+ (or offset 0)
(smie-indent-virtual)))))))

(defadvice smie-indent-comment (around elixir-mode-patch activate)
(if (not (eq major-mode 'elixir-mode))
(progn ad-do-it)
(setq ad-return-value
(and (smie-indent--bolp)
(let ((pos (point)))
(save-excursion
(beginning-of-line)
(and (re-search-forward comment-start-skip (line-end-position) t)
(eq pos (or (match-end 1) (match-beginning 0))))))
(save-excursion
(forward-comment (point-max))
(skip-chars-forward " \t\r\n")
(unless
(save-excursion
(let ((next (funcall smie-forward-token-function)))
(or (if (zerop (length next))
(or (eobp) (eq (car (syntax-after (point))) 5)))
(rassoc next smie-closer-alist))))
(smie-indent-calculate))))))))

;; FIXME: This is me being lazy. CL is a compile-time dep only.
;; (But for now, there is no real file-compilation plot, so let's
;; scrape by with the runtime dep.)
Expand Down