Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarao/multi-mode-util
A package of Emacs Lisp for easy-to-use multiple major mode.
https://github.com/tarao/multi-mode-util
emacs emacs-lisp
Last synced: 12 days ago
JSON representation
A package of Emacs Lisp for easy-to-use multiple major mode.
- Host: GitHub
- URL: https://github.com/tarao/multi-mode-util
- Owner: tarao
- Created: 2010-04-22T20:46:46.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2013-05-07T23:16:21.000Z (almost 12 years ago)
- Last Synced: 2024-12-03T21:13:26.347Z (2 months ago)
- Topics: emacs, emacs-lisp
- Language: Emacs Lisp
- Size: 123 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= multi-mode-util
== Usage
Locate multi-mode-util.el, multi-mode+viper.el and
multi-mode+evil.el somewhere in your load path.Write the following line in your .emacs.
(require 'multi-mode-util)
Then you will be able to use functions listed bellow.
- multi-mode-init
- multi-mode-quit
- multi-install-chunk-finder
- multi-run-in-base-bufferThis package fixes the following problems in the original multi-mode.
- Undo/redo-ing is inconsistent in multiple modes.
- Activating mark (especially with transient-mark-mode) across the boundary between multiple modes does not work.
- States of viper-mode get inconsistent in multiple modes.
- States of evil-mode get inconsistent in multiple modes.
- Fontification by font-lock-mode does not work properly.
- A lock file is produced even if the file is not modified. (See {issue #1}[https://github.com/tarao/multi-mode-util/issues/1])== Requirement
multi-mode.el:: http://www.loveshack.ukfsn.org/emacs/multi-mode.el
== Example 1
If you are editing HTML file with embedded Python code between
\ and ?>, then using the following settings
provides you html-mode in HTML code and python-mode
in Python code.(require 'multi-mode-util)
(defun pytml-mode ()
"Treat the current buffer as a pytml buffer."
(interactive)
(html-mode)
(multi-install-chunk-finder
"<\\?python[\r\n\t ]" "[\r\n\t ]\\?>" 'python-mode))
(setq auto-mode-alist (cons '("\\.pytml$" . pytml-mode) auto-mode-alist))== Example 2
hatena-diary-super-pre-notation in the following code enables
specific major mode for certain programming language in the text
between >|language| and ||\<. text-mode
specified to multi-mode-init is used for the rest of the text
in the buffer.(require 'multi-mode-util)
(setq hatena-diary-super-pre-languages '(java javascript lisp ruby))
(defun hatena-diary-super-pre-notation ()
(interactive)
(multi-mode-init 'text-mode)
(dolist (l hatena-diary-super-pre-languages)
(let ((str (symbol-name l)))
(multi-install-chunk-finder (concat "^>|" str "|$") "^||<$"
(intern (concat str "-mode"))))))== Functions
=== multi-mode-init (&optional BASE-MODE)
This function sets the base major mode BASE-MODE for the
buffer. It is equivalent to (multi-install-mode BASE-MODE nil
t) and this is implicitly done by the first call of
multi-install-mode for a non-base major mode. So, (unlike in
the older versions) you don't need to call this function explicitly.=== multi-mode-quit ()
Quit multi-mode. All indirect buffers for non-base major
modes are killed.=== multi-install-chunk-finder (START-PAT END-PAT MODE)
This function installs a non-base major mode MODE. The major
mode will be activated in portions of buffer between strings matching
with START-PAT and END-PAT regular expressions.=== multi-run-in-base-buffer (FUNC &optional TRACK-POSITION)
This function advises a function specified by symbol FUNC
being called in the base major mode. Unless TRACK-POSITION
is t, the cursor position will be restored after the function
call.