[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 34c3a19 212/433: Updated mode preferences to check fboundp
From: |
Dmitry Gutov |
Subject: |
[elpa] master 34c3a19 212/433: Updated mode preferences to check fboundp when regions are created. |
Date: |
Thu, 15 Mar 2018 19:44:03 -0400 (EDT) |
branch: master
commit 34c3a1928ecd317dbd8b6374983727b8642ab7b3
Author: viritrilbia <viritrilbia>
Commit: viritrilbia <viritrilbia>
Updated mode preferences to check fboundp when regions are created.
---
TODO | 7 +------
mmm-cmds.el | 5 ++---
mmm-region.el | 5 ++---
mmm-sample.el | 4 ++--
mmm-univ.el | 2 +-
mmm-utils.el | 15 +-------------
mmm-vars.el | 65 +++++++++++++++++++++++++++++++++++++++++------------------
7 files changed, 54 insertions(+), 49 deletions(-)
diff --git a/TODO b/TODO
index f945605..97c1dab 100644
--- a/TODO
+++ b/TODO
@@ -3,12 +3,7 @@ Hey Emacs, this is a -*-text-*- file!
To Do List for MMM Mode
=======================
-INFO FILE!! In addition to finishing it, updating it, etc., think
-about making it less flat: turning sections into subsections, chapters
-to sections, and adding new chapters. Also standardize punctuation to
-double spaces after sentences.
-
-Custom mode functions.
+Custom mode functions like `mason-mode'.
Make Mason work a little better with PSGML. The fix I've found works,
but it would be nifty if MMM could do it automatically. Maybe the
diff --git a/mmm-cmds.el b/mmm-cmds.el
index 116cb07..6e35758 100644
--- a/mmm-cmds.el
+++ b/mmm-cmds.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-cmds.el,v 1.13 2001/01/15 04:56:25 mas Exp $
+;; Version: $Id: mmm-cmds.el,v 1.14 2001/02/08 23:37:53 viritrilbia Exp $
;;{{{ GPL
@@ -278,8 +278,7 @@ MODIFIERS, the dotted list becomes simply BASIC-KEY."
(cdr (assoc front-str match-face)))
(t
(plist-get class :face)))))
- (unless (fboundp submode)
- (setq submode (cdr (assq submode mmm-major-mode-preferences))))
+ (setq submode (mmm-modename->function submode))
(mmm-make-region
submode beg end :front front-str :back back-str
:face face
diff --git a/mmm-region.el b/mmm-region.el
index b93952d..2d5bb90 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-region.el,v 1.30 2001/02/03 01:39:28 mas Exp $
+;; Version: $Id: mmm-region.el,v 1.31 2001/02/08 23:37:53 viritrilbia Exp $
;;{{{ GPL
@@ -246,8 +246,7 @@ un-keyword-ified."
;; allowed to sit inside others.
(when (mmm-overlays-in beg end)
(signal 'mmm-invalid-parent nil))
- (unless (fboundp submode)
- (setq submode (cdr (assq submode mmm-major-mode-preferences))))
+ (setq submode (mmm-modename->function submode))
(when submode
(mmm-update-mode-info submode))
;; Conditionally sticky overlays are by default sticky. Then the
diff --git a/mmm-sample.el b/mmm-sample.el
index 0a1d6a0..81e1271 100644
--- a/mmm-sample.el
+++ b/mmm-sample.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-sample.el,v 1.17 2001/02/08 21:41:30 viritrilbia Exp $
+;; Version: $Id: mmm-sample.el,v 1.18 2001/02/08 23:37:53 viritrilbia Exp $
;;{{{ GPL
@@ -32,7 +32,7 @@
;;; Code:
(require 'mmm-auto)
-(require 'mmm-utils)
+(require 'mmm-vars)
;;{{{ CSS embedded in HTML
diff --git a/mmm-univ.el b/mmm-univ.el
index 34c6a76..7c16df2 100644
--- a/mmm-univ.el
+++ b/mmm-univ.el
@@ -33,7 +33,7 @@
;;; Code:
(require 'mmm-auto)
-(require 'mmm-utils)
+(require 'mmm-vars)
(defun mmm-univ-get-mode (string)
(string-match "[a-zA-Z-]+" string)
diff --git a/mmm-utils.el b/mmm-utils.el
index ec43d02..ec15497 100644
--- a/mmm-utils.el
+++ b/mmm-utils.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-utils.el,v 1.11 2001/02/08 21:41:30 viritrilbia Exp $
+;; Version: $Id: mmm-utils.el,v 1.12 2001/02/08 23:37:53 viritrilbia Exp $
;;{{{ GPL
@@ -32,7 +32,6 @@
;;; Code:
(require 'cl)
-(require 'mmm-vars)
;;{{{ Valid Buffer
@@ -138,18 +137,6 @@ string."
(match-end 0)))))
;;}}}
-;;{{{ Ensure submode name
-
-(defun mmm-ensure-modename (symbol)
- "Return SYMBOL if it is a valid submode name, else nil.
-Valid submode names are either `fboundp' or present as the `car' of an
-element in `mmm-major-mode-preferences'."
- (if (or (fboundp symbol)
- (assq symbol mmm-major-mode-preferences))
- symbol
- nil))
-
-;;}}}
(provide 'mmm-utils)
diff --git a/mmm-vars.el b/mmm-vars.el
index cec8098..a39db0b 100644
--- a/mmm-vars.el
+++ b/mmm-vars.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-vars.el,v 1.42 2001/02/08 21:41:30 viritrilbia Exp $
+;; Version: $Id: mmm-vars.el,v 1.43 2001/02/08 23:37:53 viritrilbia Exp $
;;{{{ GPL
@@ -309,33 +309,58 @@ unnecessary. It probably won't go away, though."
;;{{{ Preferred Major Modes
(defcustom mmm-major-mode-preferences
- `((perl . ,(if (fboundp 'cperl-mode) 'cperl-mode 'perl-mode))
- (javascript . ,(if (fboundp 'javascript-mode) 'javascript-mode 'c++-mode))
- (java . ,(if (fboundp 'jde-mode) 'jde-mode 'java-mode))
- (css . ,(if (fboundp 'css-mode) 'css-mode 'c++-mode)))
+ '((perl cperl-mode perl-mode)
+ (javascript javascript-mode c++-mode)
+ (java jde-mode java-mode c++-mode)
+ (css css-mode c++-mode))
"User preferences about what major modes to use.
-Each element has the form \(LANGUAGE . MODE) where LANGUAGE is the
-name of a programming language such as `perl' as a symbol, and MODE is
-the major mode to use, such as `cperl-mode' or `perl-mode'."
+Each element has the form \(LANGUAGE . MODES) where LANGUAGE is the
+name of a programming language such as `perl' as a symbol, and MODES
+is a list of possible major modes to use, such as `cperl-mode' or
+`perl-mode'. The first element of MODES which is `fboundp' is used
+for submodes of LANGUAGE. The last element of MODES should be a mode
+which will always be available."
:group 'mmm
:type '(repeat (cons symbol
- (restricted-sexp :match-alternatives
- (commandp)))))
+ (repeat
+ (restricted-sexp :match-alternatives
+ (fboundp))))))
-(defun mmm-set-major-mode-preferences (language mode &optional default)
+(defun mmm-add-to-major-mode-preferences (language mode &optional default)
"Set the preferred major mode for LANGUAGE to MODE.
-This sets the value of `mmm-major-mode-preferences'. If there is
-already a mode specified for LANGUAGE, and DEFAULT is nil or
-unsupplied, then it is changed. If DEFAULT is non-nil, then any
-existing mode is unchanged. This may be used by packages to ensure
-that some mode is present, but not override any user-specified mode."
+This sets the value of `mmm-major-mode-preferences'. If DEFAULT is
+nil or unsupplied, MODE is added at the front of the list of modes for
+LANGUAGE. If DEFAULT is non-nil, then it is added at the end. This
+may be used by packages to ensure that some mode is present, but not
+override any user-specified mode."
(let ((pair (assq language mmm-major-mode-preferences)))
(if pair
- ;; Existing mode preference
- (unless default
- (setcdr pair mode))
+ ;; Existing mode preferences
+ (if default
+ (setcdr pair (cons mode (cdr pair)))
+ (setcdr pair (append (cdr pair) (list mode))))
;; No existing mode preference
- (add-to-list 'mmm-major-mode-preferences (cons language mode)))))
+ (add-to-list 'mmm-major-mode-preferences (list language mode)))))
+
+(defun mmm-ensure-modename (symbol)
+ "Return SYMBOL if it is a valid submode name, else nil.
+Valid submode names are either `fboundp' or present as the `car' of an
+element in `mmm-major-mode-preferences'."
+ (if (or (fboundp symbol)
+ (assq symbol mmm-major-mode-preferences))
+ symbol
+ nil))
+
+(defun mmm-modename->function (mode)
+ "Convert MODE to a mode function, nil if impossible.
+Valid submode names are either `fboundp' or present as the `car' of an
+element in `mmm-major-mode-preferences'. In the latter case, the
+first `fboundp' element of the `cdr' is returned, or nil if none."
+ (if (fboundp mode)
+ mode
+ (car (remove-if-not
+ #'fboundp
+ (cdr (assq mode mmm-major-mode-preferences))))))
;;}}}
;;{{{ Key Bindings
- [elpa] master d242111 258/433: *** empty log message ***, (continued)
- [elpa] master d242111 258/433: *** empty log message ***, Dmitry Gutov, 2018/03/15
- [elpa] master c75f330 317/433: Merge pull request #15 from dgutov/master, Dmitry Gutov, 2018/03/15
- [elpa] master c1997e1 313/433: Revert unintended check-in of mmm-erb changes, Dmitry Gutov, 2018/03/15
- [elpa] master c42fcb2 286/433: Compatibility fix for mode line format of Emacs 23, Dmitry Gutov, 2018/03/15
- [elpa] master b171ba0 324/433: Merge pull request #17 from dgutov/retro, Dmitry Gutov, 2018/03/15
- [elpa] master 53bd8b4 319/433: Remove duplicate entries, Dmitry Gutov, 2018/03/15
- [elpa] master 5f276a1 307/433: Update instructions and docstrings, Dmitry Gutov, 2018/03/15
- [elpa] master a0b1ecc 320/433: Merge pull request #16 from dgutov/c++-mode, Dmitry Gutov, 2018/03/15
- [elpa] master a5a24df 322/433: Fix the timer error: "Selecting deleted buffer", Dmitry Gutov, 2018/03/15
- [elpa] master 0b30852 244/433: * mmm-vars.el (mmm-c-derived-modes): Added php-mode., Dmitry Gutov, 2018/03/15
- [elpa] master 34c3a19 212/433: Updated mode preferences to check fboundp when regions are created.,
Dmitry Gutov <=
- [elpa] master 46185e0 232/433: Made C indentation style variables buffer-local., Dmitry Gutov, 2018/03/15
- [elpa] master fee1b52 211/433: Added file with Emacs-related macros from Alan Shutko., Dmitry Gutov, 2018/03/15
- [elpa] master 3c68c28 235/433: * mmm-sample.el (httpd-conf-perl): Added submode class from Rob, Dmitry Gutov, 2018/03/15
- [elpa] master c8cfb89 346/433: * mmm-noweb.el: Qualify the "doesn't work" statement., Dmitry Gutov, 2018/03/15
- [elpa] master 8e7e76b 355/433: Move html-js and html-css classes from mmm-erb to mmm-sample, Dmitry Gutov, 2018/03/15
- [elpa] master 4c51cd9 315/433: Merge pull request #13 from dgutov/master, Dmitry Gutov, 2018/03/15
- [elpa] master 23be0d3 272/433: * mmm-vars.el (mmm-save-local-variables): Updated cc-mode local, Dmitry Gutov, 2018/03/15
- [elpa] master 423ead2 353/433: Say goodbye to Emacs 19, Dmitry Gutov, 2018/03/15
- [elpa] master 5bff562 304/433: Add a few docstrings to make checkdoc happier., Dmitry Gutov, 2018/03/15
- [elpa] master 3710268 350/433: Some compatibiliy tweaks, Dmitry Gutov, 2018/03/15