emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sass-mode 3930ddc 05/31: add sass-output-region() and sass


From: ELPA Syncer
Subject: [nongnu] elpa/sass-mode 3930ddc 05/31: add sass-output-region() and sass-output-buffer()
Date: Sun, 29 Aug 2021 11:29:36 -0400 (EDT)

branch: elpa/sass-mode
commit 3930ddcb2ce89fa770c1dacf0155f7b81eb25eef
Author: kmori <mori.dev.asdf@gmail.com>
Commit: kmori <mori.dev.asdf@gmail.com>

    add sass-output-region() and sass-output-buffer()
---
 sass-mode.el | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/sass-mode.el b/sass-mode.el
index 11d8993..09bd046 100644
--- a/sass-mode.el
+++ b/sass-mode.el
@@ -181,9 +181,17 @@ LIMIT is the limit of the search."
 
 ;; Mode setup
 
+(defvar sass-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-r" 'sass-output-region)
+    (define-key map "\C-c\C-l" 'sass-output-buffer)
+    map))
+
 ;;;###autoload
 (define-derived-mode sass-mode haml-mode "Sass"
-  "Major mode for editing Sass files."
+  "Major mode for editing Sass files.
+
+\\{sass-mode-map}"
   (set-syntax-table sass-syntax-table)
   (setq font-lock-extend-region-functions
         '(font-lock-extend-region-wholelines 
font-lock-extend-region-multiline))
@@ -201,6 +209,24 @@ LIMIT is the limit of the search."
         if (looking-at opener) return nil
         finally return t))
 
+;; Command
+
+(defun sass-output-region (start end)
+  "Displays the CSS output for the current block of Sass code.
+Called from a program, START and END specify the region to indent."
+  (interactive "r")
+  (let* ((text (buffer-substring-no-properties start end))
+         (command (format "ruby -rubygems -e \"require 'sass'; puts 
Sass::Engine.new('%s').render\"" text)))
+  (kill-new text)
+  (with-temp-buffer
+    (yank)
+    (shell-command-on-region (point-min) (point-max) command "sass-output"))))
+
+(defun sass-output-buffer ()
+  "Displays the CSS output for entire buffer."
+  (interactive)
+  (sass-output-region (point-min) (point-max)))
+
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]