dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

css-mode-expansions.el (1802B)


      1 ;;; css-mode-expansions.el --- CSS-specific expansions for expand-region
      2 
      3 ;; Copyright (C) 2011-2020  Free Software Foundation, Inc
      4 
      5 ;; Author: Magnar Sveen <magnars@gmail.com>
      6 ;; Keywords: marking region
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 
     23 ;; For now I have only found the need for mark-css-declaration.
     24 ;;
     25 ;; Feel free to contribute any other expansions for CSS at
     26 ;;
     27 ;;     https://github.com/magnars/expand-region.el
     28 
     29 ;;; Code:
     30 
     31 (require 'expand-region-core)
     32 
     33 (defun er/mark-css-declaration ()
     34   "Marks one CSS declaration, eg. font-weight: bold;"
     35   (interactive)
     36   (search-backward-regexp "[;{] ?" (line-beginning-position))
     37   (forward-char)
     38   (set-mark (point))
     39   (search-forward ";" (line-end-position))
     40   (exchange-point-and-mark))
     41 
     42 (defun er/add-css-mode-expansions ()
     43   "Adds CSS-specific expansions for buffers in css-mode"
     44   (set (make-local-variable 'er/try-expand-list) (append
     45                                                   er/try-expand-list
     46                                                   '(er/mark-css-declaration))))
     47 
     48 (er/enable-mode-expansions 'css-mode 'er/add-css-mode-expansions)
     49 
     50 (provide 'css-mode-expansions)
     51 
     52 ;; css-mode-expansions.el ends here