From 4898b1669b54a8afca3303e70f01a9825cbe01d1 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 7 Dec 2014 01:18:04 +0000 Subject: Patch sx and sx-question-print to use sx-babel. --- sx-question-print.el | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'sx-question-print.el') diff --git a/sx-question-print.el b/sx-question-print.el index 2a0a035..fe64392 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -431,29 +431,19 @@ If ID is nil, use FALLBACK-ID instead." "If there's a pre block ahead, handle it, skip it and return t. Handling means to turn it into a button and remove erroneous font-locking." - (let (beg end text) + (let (beg end) (when (markdown-match-pre-blocks (save-excursion (skip-chars-forward "\r\n[:blank:]") (setq beg (point)))) (setq end (point)) - (setq text - (sx--unindent-text - (buffer-substring - (save-excursion - (goto-char beg) - (line-beginning-position)) - end))) - (put-text-property beg end 'display nil) - (make-text-button - beg end - 'face 'markdown-pre-face - 'sx-button-copy text - :type 'sx-question-mode-code-block)))) + (sx-babel--make-pre-button + (buffer-substring + (save-excursion + (goto-char beg) + (line-beginning-position)) + end))))) (provide 'sx-question-print) ;;; sx-question-print.el ends here -;; Local Variables: -;; lexical-binding: t -;; End: -- cgit v1.2.3 From 42157310ba599a05dce1664080213e31ab00a2d4 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 8 Dec 2014 13:10:27 +0000 Subject: Don't require sx Requiring sx is not needed because the macro is autoloaded. --- sx-question-print.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sx-question-print.el') diff --git a/sx-question-print.el b/sx-question-print.el index fe64392..6b65d70 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -23,11 +23,9 @@ ;;; Code: (require 'markdown-mode) (require 'sx-button) -(eval-when-compile - (require 'rx)) - (require 'sx) (require 'sx-question) +(require 'sx-babel) (defgroup sx-question-mode nil "Customization group for sx-question-mode." -- cgit v1.2.3 From 635bbc2a3e410f5b97a3f20e5b790712cc873cc2 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 9 Dec 2014 14:13:31 +0000 Subject: Fix some implementation bugs --- sx-babel.el | 10 +++++++--- sx-question-print.el | 9 ++++----- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'sx-question-print.el') diff --git a/sx-babel.el b/sx-babel.el index 7da24a5..5544642 100644 --- a/sx-babel.el +++ b/sx-babel.el @@ -30,7 +30,11 @@ (defvar sx-babel-major-mode-alist `((,(rx (or "*" "#+")) org-mode) - (,(rx (or "[" "(" ";" "#(")) emacs-lisp-mode)) + (,(rx (or "[" "(" ";" "#(")) emacs-lisp-mode) + ;; @TODO: Make shell-mode work here. Currently errors because it + ;; needs a process. `sh-mode' isn't as nice. + (,(rx (or "$ " "# ")) sh-mode) + ) "List of cons cells determining which major-mode to use when. Each car is a rule and each cdr is a major-mode. The first rule which is satisfied activates the major-mode. @@ -59,7 +63,7 @@ on a match.") (sx-babel--determine-and-activate-major-mode) (font-lock-fontify-region (point-min) (point-max)) (goto-char (point-min)) - (let ((space (make-string indent " "))) + (let ((space (make-string indent ?\s))) (while (not (eobp)) (insert space) (forward-line 1))) @@ -78,7 +82,7 @@ on a match.") (let ((kar (car cell))) (when (if (stringp kar) (looking-at kar) (funcall kar)) (setq alist nil) - (funcall (cdr cell))))))) + (funcall (cadr cell))))))) (defun sx-babel--unindent-buffer () "Remove absolute indentation in current buffer. diff --git a/sx-question-print.el b/sx-question-print.el index 6b65d70..653ebab 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -436,11 +436,10 @@ font-locking." (setq beg (point)))) (setq end (point)) (sx-babel--make-pre-button - (buffer-substring - (save-excursion - (goto-char beg) - (line-beginning-position)) - end))))) + (save-excursion + (goto-char beg) + (line-beginning-position)) + end)))) (provide 'sx-question-print) ;;; sx-question-print.el ends here -- cgit v1.2.3