dotemacs

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

sml-mode-expansions.el (2081B)


      1 ;;; sml-mode-expansions.el --- Expansions for expand-region to be used in sml-mode  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2012-2023  Free Software Foundation, Inc
      4 
      5 ;; Author: Alexis Gallagher
      6 ;; Based on js-mode-expansions by: Magnar Sveen <magnars@gmail.com>
      7 ;; Keywords: marking region
      8 
      9 ;; This program is free software; you can redistribute it and/or modify
     10 ;; it under the terms of the GNU General Public License as published by
     11 ;; the Free Software Foundation, either version 3 of the License, or
     12 ;; (at your option) any later version.
     13 
     14 ;; This program is distributed in the hope that it will be useful,
     15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 ;; GNU General Public License for more details.
     18 
     19 ;; You should have received a copy of the GNU General Public License
     20 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
     21 
     22 ;;; Commentary:
     23 
     24 ;; Provides extra expansions for sml-mode:
     25 ;; - various expression (case, if, let)
     26 ;; - fun bindings
     27 ;; 
     28 ;; Tested with sml-mode version 6.3
     29 ;; 
     30 ;; Feel free to contribute any other expansions for SML at
     31 ;;
     32 ;;     https://github.com/magnars/expand-region.el
     33 
     34 ;;; Code:
     35 
     36 (require 'expand-region-core)
     37 (declare-function sml-find-matching-starter "sml-mode")
     38 
     39 ;; TODO: comma-delimited elements within a list,tuple,record
     40 ;; TODO: match expression, patterns
     41 ;; TODO: individual field, record type
     42 ;; TODO: head-or-tail, then cons expression
     43 
     44 (defun er/sml-mark-keyword-prefixed-expression ()
     45   "Mark the surrounding expression."
     46   (interactive)
     47   (progn 
     48     (sml-find-matching-starter '("case" "let" "if" "raise"))
     49     (mark-sexp)))
     50 
     51 
     52 (defun er/add-sml-mode-expansions ()
     53   "Adds expansions for buffers in `sml-mode'."
     54   (set (make-local-variable 'er/try-expand-list)
     55        (append er/try-expand-list
     56 	       '(sml-mark-function
     57 		 er/sml-mark-keyword-prefixed-expression
     58 		 mark-sexp))))
     59 
     60 (er/enable-mode-expansions 'sml-mode #'er/add-sml-mode-expansions)
     61 
     62 (provide 'sml-mode-expansions)
     63 
     64 ;; sml-mode-expansions.el ends here