Welcome in 2026 adding lot of features

This commit is contained in:
nemunaire 2026-01-24 20:30:42 +08:00
commit ea3345a03e
211 changed files with 58 additions and 80682 deletions

View file

@ -1,388 +0,0 @@
;;; edit-indirect.el --- Edit regions in separate buffers -*- lexical-binding: t -*-
;; Author: Fanael Linithien <fanael4@gmail.com>
;; URL: https://github.com/Fanael/edit-indirect
;; Version: 0.1.5
;; Package-Requires: ((emacs "24.3"))
;; This file is NOT part of GNU Emacs.
;; SPDX-License-Identifier: BSD-2-clause
;;
;; Copyright (c) 2014-2017, Fanael Linithien
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;; * Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; Commentary:
;; Edit regions in separate buffers, like `org-edit-src-code' but for arbitrary
;; regions.
;;
;; See the docstring of `edit-indirect-region' for details.
;;; Code:
(defgroup edit-indirect nil
"Editing regions in separate buffers."
:group 'editing)
(defcustom edit-indirect-guess-mode-function #'edit-indirect-default-guess-mode
"The function used to guess the major mode of an edit-indirect buffer.
It's called with the edit-indirect buffer as the current buffer.
It's called with three arguments, the parent buffer, the beginning
and the end of the parent buffer region being editing.
Note that the buffer-local value from the parent buffer is used."
:type 'function
:group 'edit-indirect)
(defcustom edit-indirect-after-creation-hook nil
"Functions called after the edit-indirect buffer is created.
The functions are called with the edit-indirect buffer as the
current buffer.
Note that the buffer-local value from the parent buffer is used."
:type 'hook
:group 'edit-indirect)
(defcustom edit-indirect-before-commit-hook nil
"Functions called before the edit-indirect buffer is committed.
The functions are called with the edit-indirect buffer as the
current buffer.
Note that the buffer-local value from the edit-indirect buffer is
used."
:type 'hook
:group 'edit-indirect)
(defcustom edit-indirect-before-commit-functions nil
"Functions called before an edit-indirect buffer is committed.
The functions are called with the parent buffer as the current
buffer.
Each function is called with two arguments, the beginning and the
end of the region to be changed."
:type 'hook
:group 'edit-indirect)
(defcustom edit-indirect-after-commit-functions nil
"Functions called after an edit-indirect buffer has been committed.
The functions are called with the parent buffer as the current
buffer.
Each function is called with two arguments, the beginning and the
end of the changed region."
:type 'hook
:group 'edit-indirect)
(defgroup edit-indirect-faces nil
"Faces used in `edit-indirect'."
:group 'edit-indirect
:group 'faces
:prefix "edit-indirect")
(defface edit-indirect-edited-region
'((t :inherit secondary-selection))
"Face used to highlight an indirectly edited region."
:group 'edit-indirect-faces)
;; Emacs <= 24.3 has no `define-error'.
(let* ((user-error-conditions (get 'user-error 'error-conditions))
(define-user-error (lambda (name message)
(put name 'error-conditions
(cons name user-error-conditions))
(put name 'error-message message))))
(funcall define-user-error 'edit-indirect-overlapping
"Indirectly edited regions cannot overlap")
(funcall define-user-error 'edit-indirect-read-only
"Text is read-only, modify the edit-indirect buffer instead")
(funcall define-user-error 'edit-indirect-not-indirect
"This is not an edit-indirect buffer"))
(defvar edit-indirect--overlay)
(defvar edit-indirect--should-quit-window nil)
;;;###autoload
(defun edit-indirect-region (beg end &optional display-buffer)
"Edit the region BEG..END in a separate buffer.
The region is copied, without text properties, to a separate
buffer, called edit-indirect buffer, and
`edit-indirect-guess-mode-function' is called to set the major
mode.
When done, exit with `edit-indirect-commit', which will remove the
original region and replace it with the edited version; or with
`edit-indirect-abort', which will drop the modifications.
This differs from `clone-indirect-buffer' with narrowing in that
the text properties are not shared, so the parent buffer major mode
and the edit-indirect buffer major mode will not be able to tread
on each other's toes by setting up potentially conflicting text
properties, which happens surprisingly often when the font-lock
mode is used.
Edit-indirect buffers use the `edit-indirect-mode-map' keymap.
If there's already an edit-indirect buffer for BEG..END, use that.
If there's already an edit-indirect buffer active overlapping any
portion of BEG..END, an `edit-indirect-overlapping' error is
signaled.
When DISPLAY-BUFFER is non-nil or when called interactively,
display the edit-indirect buffer in some window and select it.
In any case, return the edit-indirect buffer."
(interactive
(if (or (use-region-p) (not transient-mark-mode))
(prog1 (list (region-beginning) (region-end) t)
(deactivate-mark))
(user-error "No region")))
(let ((buffer (edit-indirect--get-edit-indirect-buffer beg end)))
(when display-buffer
(with-current-buffer buffer
(setq-local edit-indirect--should-quit-window t))
(select-window (display-buffer buffer)))
buffer))
(defvar edit-indirect-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-x C-s") #'edit-indirect-save)
(define-key map (kbd "C-c '") #'edit-indirect-commit)
(define-key map (kbd "C-c C-c") #'edit-indirect-commit)
(define-key map (kbd "C-c C-k") #'edit-indirect-abort)
map)
"Keymap for edit-indirect buffers.
\\{edit-indirect-mode-map}")
(defun edit-indirect-commit ()
"Commit the modifications done in an edit-indirect buffer.
That is, replace the original region in the parent buffer with the
contents of the edit-indirect buffer.
The edit-indirect buffer is then killed.
Can be called only when the current buffer is an edit-indirect
buffer."
(interactive)
(edit-indirect--barf-if-not-indirect)
(edit-indirect--commit)
(edit-indirect--clean-up))
(defun edit-indirect-save ()
"Save the modifications done in an edit-indirect buffer.
That is, replace the original region in the parent buffer with the
contents of the edit-indirect buffer.
Can be called only when the current buffer is an edit-indirect
buffer."
(interactive)
(edit-indirect--barf-if-not-indirect)
(edit-indirect--commit))
(defun edit-indirect-abort ()
"Abort indirect editing in the current buffer and kill the buffer.
Can be called only when the current buffer is an edit-indirect
buffer."
(interactive)
(edit-indirect--barf-if-not-indirect)
(edit-indirect--abort))
(defun edit-indirect-buffer-indirect-p (&optional buffer)
"Non-nil iff the BUFFER is an edit-indirect buffer.
BUFFER defaults to the current buffer."
(save-current-buffer
(when buffer
(set-buffer buffer))
;; (not (null)) so we don't leak the overlay to the outside world.
(not (null edit-indirect--overlay))))
(defun edit-indirect-default-guess-mode (_parent-buffer _beg _end)
"Guess the major mode for an edit-indirect buffer.
It's done by calling `normal-mode'."
(normal-mode))
(defvar edit-indirect--overlay nil
"The overlay spanning the region of the parent buffer being edited.
It's also used as the variable determining if we're in an
edit-indirect buffer at all.")
(make-variable-buffer-local 'edit-indirect--overlay)
(put 'edit-indirect--overlay 'permanent-local t)
;; Normally this would use `define-minor-mode', but that makes the mode function
;; interactive, which we don't want, because it's just an implementation detail.
(defun edit-indirect--mode (overlay)
"Turn the `edit-indirect--mode' \"minor mode\" on.
OVERLAY is the value to set `edit-indirect--overlay' to."
(setq edit-indirect--overlay overlay)
(add-hook 'kill-buffer-hook #'edit-indirect--abort-on-kill-buffer nil t))
(with-no-warnings
(add-minor-mode
'edit-indirect--overlay " indirect" edit-indirect-mode-map nil #'ignore))
(defun edit-indirect--get-edit-indirect-buffer (beg end)
"Return an edit-indirect buffer for the region BEG..END.
If there's already an edit-indirect buffer active overlapping any
portion of BEG..END, an `edit-indirect-overlapping' error is
signaled."
(let ((old-overlay (edit-indirect--search-for-edit-indirect beg end)))
(cond
((null old-overlay)
(let ((overlay (edit-indirect--create-overlay beg end)))
(edit-indirect--create-indirect-buffer beg end overlay)))
((and (= beg (overlay-start old-overlay))
(= end (overlay-end old-overlay)))
(overlay-get old-overlay 'edit-indirect-buffer))
(t
(signal 'edit-indirect-overlapping '())))))
(defun edit-indirect--search-for-edit-indirect (beg end)
"Return an existing edit-indirect overlay for some region inside BEG..END.
If there's no indirectly edited region inside BEG..END, return
nil."
(catch 'done
(dolist (overlay (overlays-in beg end))
(when (overlay-get overlay 'edit-indirect-buffer)
(throw 'done overlay)))
nil))
(defmacro edit-indirect--buffer-local-value (buffer variable)
"Get the BUFFER local value of VARIABLE.
VARIABLE shall be a symbol."
(unless (symbolp variable)
(signal 'wrong-type-argument (list #'symbolp variable)))
;; `with-current-buffer' is used instead of `buffer-local-value' because
;; the latter doesn't give warnings about free variables when
;; byte-compiled.
`(with-current-buffer ,buffer ,variable))
(defun edit-indirect--create-indirect-buffer (beg end overlay)
"Create an edit-indirect buffer and return it.
BEG..END is the parent buffer region to insert.
OVERLAY is the overlay, see `edit-indirect--overlay'."
(let ((buffer (generate-new-buffer (format "*edit-indirect %s*" (buffer-name))))
(parent-buffer (current-buffer)))
(overlay-put overlay 'edit-indirect-buffer buffer)
(with-current-buffer buffer
(insert-buffer-substring-no-properties parent-buffer beg end)
(set-buffer-modified-p nil)
(edit-indirect--mode overlay)
;; Use the buffer-local values from the parent buffer. Don't retrieve the
;; values before actual uses in case these variables are changed by some
;; of the many possible hooks.
(funcall (edit-indirect--buffer-local-value
parent-buffer edit-indirect-guess-mode-function)
parent-buffer beg end)
(let ((edit-indirect-after-creation-hook
(edit-indirect--buffer-local-value
parent-buffer edit-indirect-after-creation-hook)))
(run-hooks 'edit-indirect-after-creation-hook)))
buffer))
(defun edit-indirect--create-overlay (beg end)
"Create the edit-indirect overlay and return it.
BEG and END specify the region the overlay should encompass."
(let ((overlay (make-overlay beg end)))
(overlay-put overlay 'face 'edit-indirect-edited-region)
(overlay-put overlay 'modification-hooks '(edit-indirect--barf-read-only))
(overlay-put overlay 'insert-in-front-hooks '(edit-indirect--barf-read-only))
overlay))
(defvar edit-indirect--inhibit-read-only nil
"Non-nil means disregard read-only status of indirectly-edited region.")
(defun edit-indirect--barf-read-only (_ov _after _beg _end &optional _len)
"Signal an error because the text is read-only.
No error is signaled if `inhibit-read-only' or
`edit-indirect--inhibit-read-only' is non-nil."
(unless (or inhibit-read-only edit-indirect--inhibit-read-only)
(signal 'edit-indirect-read-only '())))
(defun edit-indirect--commit ()
"Commit the modifications done in an edit-indirect buffer."
(run-hooks 'edit-indirect-before-commit-hook)
(let ((beg (overlay-start edit-indirect--overlay))
(end (overlay-end edit-indirect--overlay))
(buffer (current-buffer))
(edit-indirect--inhibit-read-only t))
(with-current-buffer (overlay-buffer edit-indirect--overlay)
(save-excursion
(let ((beg-marker (copy-marker beg))
(end-marker (copy-marker end)))
(edit-indirect--run-hook-with-positions
'edit-indirect-before-commit-functions beg-marker end-marker)
(save-match-data
(set-match-data (list beg-marker end-marker))
(replace-match (with-current-buffer buffer
(buffer-substring-no-properties 1 (1+ (buffer-size))))
t t))
(edit-indirect--run-hook-with-positions
'edit-indirect-after-commit-functions beg-marker (point))
(set-marker beg-marker nil)
(set-marker end-marker nil))))))
(defun edit-indirect--run-hook-with-positions (hook beg end)
"Run HOOK with the specified positions BEG and END.
HOOK should be a symbol, a hook variable.
The functions are passed integer positions.
If a function changes the buffer contents, the next function will be
called with updated positions."
(let ((beg-marker (unless (markerp beg) (copy-marker beg)))
(end-marker (unless (markerp end) (copy-marker end))))
(run-hook-wrapped hook
(lambda (f beg end)
(funcall f (marker-position beg) (marker-position end))
nil)
(or beg-marker beg) (or end-marker end))
(when beg-marker (set-marker beg-marker nil))
(when end-marker (set-marker end-marker nil))))
(defun edit-indirect--abort ()
"Abort indirect edit."
(edit-indirect--clean-up))
(defun edit-indirect--clean-up ()
"Clean up an edit-indirect buffer."
(delete-overlay edit-indirect--overlay)
;; Kill the overlay reference so that `edit-indirect--abort-on-kill-buffer'
;; won't try to call us again.
(setq edit-indirect--overlay nil)
;; If we created a window, get rid of it. Kill the buffer we created.
(if edit-indirect--should-quit-window
(quit-window t)
(kill-buffer)))
(defun edit-indirect--abort-on-kill-buffer ()
"Abort indirect edit.
Should be called only from `kill-buffer-hook'."
(when edit-indirect--overlay
(edit-indirect--abort)))
(defun edit-indirect--barf-if-not-indirect ()
"Signal an error if the current buffer is not an edit-indirect buffer.
The error signaled is `edit-indirect-not-indirect'."
(unless edit-indirect--overlay
(signal 'edit-indirect-not-indirect '())))
(provide 'edit-indirect)
;;; edit-indirect.el ends here

View file

@ -1,512 +0,0 @@
;;; edje-mode-el -- Major mode for editing Edje files
;; Author: Gustavo Sverzut Barbieri <barbieri@gmail.com>
;; Created: 2007-07-23
;; Keywords: Edje major-mode
;; Url: http://barbieri-playground.googlecode.com/svn/dot-files/edje-mode.el
;; (if you find this file have problems, check that Url and request update)
;; Copyright (C) 2007 Gustavo Sverzut Barbieri <barbieri@gmail.com>
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA
;;; Commentary:
;;
;; This mode is based on tutorial from Scott Andrew Borton:
;; http://two-wugs.net/emacs/mode-tutorial.html
(defvar edje-mode-hook nil)
(defun number-or-nil-to-string (v &optional default)
(cond ((numberp v) (number-to-string v))
((stringp v) (if (string= v "") (number-to-string default) v))
(t (number-to-string default))))
(defun non-empty-string (s)
(and (not (eq 'nil s))
(not (string= "" s))))
(defun edje-new-program-action-signal-emit (source emission)
"Insert new program SIGNAL_EMIT"
(interactive "ssource: \nsemission: ")
(insert
(concat
" action: SIGNAL_EMIT \"" source "\" \"" emission "\";\n"
)))
(defun edje-new-program-action-state-set (state value target)
"Insert new program STATE_SET"
(interactive "sstate: \nsvalue (0.0): \nstarget: ")
(insert
(concat
" action: STATE_SET \"" state "\" "
(number-or-nil-to-string value 0.0) ";\n"
" target: \"" target "\";\n"
)))
(defun edje-new-program-action (action)
"Insert new program action"
(interactive "saction: ")
(setq action (upcase action))
(cond ((string= action "STATE_SET")
(edje-new-program-action-state-set "" 0.0 ""))
((string= action "SIGNAL_EMIT")
(edje-new-program-action-signal-emit "" ""))
))
(defun edje-new-program (name signal source action)
"Insert new program block"
(interactive "sname: \nssignal: \nssource: \nsaction: ")
(insert
(concat
"\n"
" program {\n"
" name: \"" name "\";\n"
(if (non-empty-string signal)
(concat " signal: \"" signal "\";\n"))
(if (non-empty-string source)
(concat " source: \"" source "\";\n"))
))
(edje-new-program-action action)
(insert
(concat
" }\n"
"\n"
)))
(defun edje-new-desc-relative (x y &optional defx defy)
"Insert new part description 'relative' line"
(interactive "sx: \nsy: ")
(insert
(concat
" relative: "
(number-or-nil-to-string x defx) " "
(number-or-nil-to-string y defy) ";\n"
)))
(defun edje-new-desc-offset (x y &optional defx defy)
"Insert new part description 'offset' line"
(interactive "sx: \nsy: ")
(insert
(concat
" offset: "
(number-or-nil-to-string x defx) " "
(number-or-nil-to-string y defy) ";\n"
)))
(defun edje-new-desc-inherit (name val)
"Insert new part description 'inherit' line"
(interactive "sname: \nsvalue: ")
(insert
(concat
" inherit: \"" name "\" "
(number-or-nil-to-string val 0.0) ";\n"
)))
(defun edje-new-desc-text (font size text)
"Insert new part description 'text' block"
(interactive "sfont: \nssize: \nstext: ")
(insert
(concat
" text {\n"
" font: \"" font "\";\n"
" size: " (number-or-nil-to-string size) ";\n"
" text: \"" text "\";\n"
" }\n"
)))
(defun edje-new-desc-image (name)
"Insert new part description 'image' block"
(interactive "sname: ")
(insert
(concat
" image {\n"
" normal: \"" name "\";\n"
" }\n"
)))
(defun edje-new-desc-color (r g b a &optional defr defg defb defa)
"Insert new part description 'color' line"
(interactive "sred: \nsgreen: \nsblue: \nsalpha: ")
(insert
(concat
" color: "
(number-or-nil-to-string r defr) " "
(number-or-nil-to-string g defg) " "
(number-or-nil-to-string b defb) " "
(number-or-nil-to-string a defa) ";\n"
)))
(defun edje-new-desc (name val &optional
r1_rx r1_ry
r2_rx r2_ry
r1_ox r1_oy
r2_ox r2_oy
part_type)
"Insert new part description block"
(interactive "sName: \nsValue: ")
(insert
(concat
" description {\n"
" state: \"" name "\" " (number-or-nil-to-string val 0.0) ";\n"))
(if (string= part_type "RECT") (edje-new-desc-color 255 255 255 255))
(insert " rel1 {\n")
(edje-new-desc-relative r1_rx r1_ry 0.0 0.0)
(edje-new-desc-offset r1_ox r1_oy 0 0)
(insert
(concat
" }\n"
" rel2 {\n"
))
(edje-new-desc-relative r2_rx r2_ry 1.0 1.0)
(edje-new-desc-offset r2_ox r2_oy -1 -1)
(insert " }\n")
(cond ((string= part_type "IMAGE") (edje-new-desc-image ""))
((string= part_type "TEXT") (edje-new-desc-text "" 10 "contents"))
)
(insert " }\n")
)
(defun edje-new-part (name type &optional
r1_rx r1_ry
r2_rx r2_ry
r1_ox r1_oy
r2_ox r2_oy)
"Insert new part"
(interactive "sName: \nsType: ")
(setq type (upcase type))
(insert
(concat
"\n"
" part {\n"
" name: \"" name "\";\n"
" type: " type ";\n"
" mouse_events: 0;\n"
))
(edje-new-desc "default" 0.0 r1_rx r1_ry r2_rx r2_ry r1_ox r1_oy r2_ox r2_oy type)
(insert
(concat
" }\n"
)))
(defun edje-setup-compile ()
(set (make-local-variable 'compile-command)
(concat "edje_cc " (buffer-file-name))
))
(defun edje-cc ()
"Runs edje_cc with current buffer."
(interactive)
(compile (edje-setup-compile)))
(defvar edje-mode-map
(let ((edje-mode-map (make-sparse-keymap)))
(define-key edje-mode-map "\C-j" 'newline-and-indent)
(define-key edje-mode-map "\C-cp" 'edje-new-part)
(define-key edje-mode-map "\C-cd" 'edje-new-desc)
(define-key edje-mode-map "\C-cr" 'edje-new-desc-relative)
(define-key edje-mode-map "\C-co" 'edje-new-desc-offset)
(define-key edje-mode-map "\C-ch" 'edje-new-desc-inherit)
(define-key edje-mode-map "\C-cc" 'edje-new-desc-color)
(define-key edje-mode-map "\C-ci" 'edje-new-desc-image)
(define-key edje-mode-map "\C-ct" 'edje-new-desc-text)
(define-key edje-mode-map "\C-cg" 'edje-new-program)
(define-key edje-mode-map "\C-ca" 'edje-new-program-action)
(define-key edje-mode-map "\C-cs" 'edje-new-program-action-state-set)
(define-key edje-mode-map "\C-ce" 'edje-new-program-action-signal-emit)
edje-mode-map)
"Keymap for Edje major mode")
(add-hook 'c-mode-hook 'edje-setup-compile)
(add-to-list 'auto-mode-alist '("\\.edc$" . edje-mode))
(defconst edje-font-lock-keywords-1
(eval-when-compile
(list
(list (concat "[ \t]*\\<"
(regexp-opt
'(
"collections"
"data"
"description"
"dragable"
"fill"
"fonts"
"group"
"image"
"images"
"origin"
"part"
"parts"
"program"
"programs"
"rel1"
"rel2"
"script"
"spectra"
"style"
"styles"
"text"
) t) "\\>\\([ \t]*{\\|\\.\\)")
'(1 font-lock-function-name-face))
))
"Major keywords")
(defconst edje-font-lock-keywords-2
(eval-when-compile
(append edje-font-lock-keywords-1
(list
(list
(concat "^\\([ \t]*\\|[ \t]*[a-z]+\\.\\|\\)\\<"
(regexp-opt
'("action"
"after"
"alias"
"align"
"angle"
"aspect"
"aspect_preference"
"base"
"border"
"clip_to"
"collections"
"color"
"color2"
"color3"
"color_class"
"color_classes"
"confine"
"data"
"description"
"dragable"
"effect"
"elipsis"
"events"
"fill"
"fit"
"fixed"
"font"
"fonts"
"gradient"
"group"
"ignore_flags"
"image"
"images"
"in"
"inherit"
"item"
"max"
"middle"
"min"
"mouse_events"
"name"
"normal"
"offset"
"origin"
"part"
"parts"
"pointer_mode"
"precise_is_inside"
"program"
"programs"
"rel1"
"rel2"
"relative"
"repeat_events"
"signal"
"size"
"smooth"
"source"
"spectra"
"spectrum"
"spread"
"state"
"step"
"style"
"styles"
"tag"
"target"
"text"
"text_class"
"text_source"
"to"
"to_x"
"to_y"
"transition"
"tween"
"type"
"use_alternate_font_metrics"
"visible"
"x"
"y"
) t) "\\>[ \t]*[:,]")
'(2 font-lock-keyword-face))
)))
"Minor keywords")
(defconst edje-font-lock-keywords-3
(eval-when-compile
(append edje-font-lock-keywords-2
(list
(list
(concat "\\<"
(regexp-opt
'(; image options (st_images_image)
"RAW"
"COMP"
"LOSSY"
"USER"
; part types (st_collections_group_parts_part_type)
"NONE"
"RECT"
"TEXT"
"IMAGE"
"SWALLOW"
"TEXTBLOCK"
"GRADIENT"
"GROUP"
; ignore flags (st_collections_group_parts_part_ignore_flags)
;"NONE"
"ON_HOLD"
; pointer mode (st_collections_group_parts_part_pointer_mode)
"AUTOGRAB"
"NOGRAB"
; aspect (st_collections_group_parts_part_description_aspect_preference)
"NONE"
"VERTICAL"
"HORIZONTAL"
"BOTH"
; text effect (st_collections_group_parts_part_effect)
"NONE"
"PLAIN"
"OUTLINE"
"SOFT_OUTLINE"
"SHADOW"
"SOFT_SHADOW"
"OUTLINE_SHADOW"
"OUTLINE_SOFT_SHADOW"
"FAR_SHADOW"
"FAR_SOFT_SHADOW"
"GLOW"
; image fill (st_collections_group_parts_part_description_fill_type)
"SCALE"
"TILE"
; program action (st_collections_group_programs_program_action)
"STATE_SET"
"ACTION_STOP"
"SIGNAL_EMIT"
"DRAG_VAL_SET"
"DRAG_VAL_STEP"
"DRAG_VAL_PAGE"
"SCRIPT"
; program transition (st_collections_group_programs_program_transition)
"LINEAR"
"SINUSOIDAL"
"ACCELERATE"
"DECELERATE"
) t) "\\>")
'(1 font-lock-builtin-face))
)))
"Enumerate values")
(defconst edje-font-lock-keywords-4
(eval-when-compile
(append edje-font-lock-keywords-3
(list
(list
(concat "[ \t]*#"
(regexp-opt
'("if"
"ifdef"
"ifndef"
"define"
"else"
"endif"
"include"
"undef") t) "[ \t]*")
'(1 font-lock-builtin-face))
)))
"CPP directives")
(defconst edje-font-lock-keywords-5
(eval-when-compile
(append edje-font-lock-keywords-4
(list
(list "[ \t]*#undef[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
'(1 font-lock-variable-name-face))
(list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)("
'(1 font-lock-function-name-face))
(list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
'(1 font-lock-variable-name-face))
)))
"CPP directives that define constants")
(defvar edje-font-lock-keywords edje-font-lock-keywords-5)
(defvar edje-mode-syntax-table
(let ((edje-mode-syntax-table (make-syntax-table)))
; This is added so entity names with underscores can be more easily parsed
(modify-syntax-entry ?_ "w" edje-mode-syntax-table)
(modify-syntax-entry ?/ ". 124b" edje-mode-syntax-table)
(modify-syntax-entry ?* ". 23" edje-mode-syntax-table)
(modify-syntax-entry ?\n "> b" edje-mode-syntax-table)
edje-mode-syntax-table)
"Syntax table for edje-mode")
(c-add-style
"edje"
'("gnu"
(indent-tabs-mode . nil)
(tab-width . 8)
(c-basic-offset . 3)
(c-backslash-column . 72)
(c-hanging-braces-alist .
((block-open after)
(brace-list-open after)
(substatement-open after))
)
(c-offsets-alist .
((statement-block-intro . +)
(defun-open . 0)
(substatement-open . 0)
(defun-block-intro . +)
(block-open . 0)
(label . +)
))))
(define-derived-mode edje-mode c-mode "Edje"
"Major mode for editing Edje files"
(interactive)
(use-local-map edje-mode-map)
(set-syntax-table edje-mode-syntax-table)
(set (make-local-variable 'font-lock-defaults) '(edje-font-lock-keywords))
(set (make-local-variable 'require-final-newline) t)
(c-set-style "edje")
(run-hooks 'edje-mode-hook)
)
(provide 'edje-mode)
;;; edje-mode.el ends here

View file

@ -1,242 +0,0 @@
;;; find-cmd.el --- Build a valid find(1) command with sexps
;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
;; Author: Philip Jackson <phil@shellarchive.co.uk>
;; Version: 0.6
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; With this module you can build up a (hopefully) valid find(1)
;; string ready for the command line. For example:
;; (find-cmd '(prune (name ".svn" ".git" ".CVS"))
;; '(and (or (name "*.pl" "*.pm" "*.t")
;; (mtime "+1"))
;; (fstype "nfs" "ufs"))))
;; will become (un-wrapped):
;; "find '/home/phil/' \\( \\( -name '.svn' -or -name '.git' -or
;; -name '.CVS' \\) -prune -or -true \\) \\( \\( \\( -name '*.pl'
;; -or -name '*.pm' -or -name '*.t' \\) -or -mtime '+1' \\) -and \\(
;; -fstype 'nfs' -or -fstype 'ufs' \\) \\)"
;;; Code:
(defconst find-constituents
'((and . find-and)
(not . find-not)
(or . find-or)
(a . find-and)
(n . find-not)
(o . find-or)
(prune . find-prune)
;; switches
(L . (0))
(P . (0))
(H . (0))
;; generic tests
(amin . (1))
(anewer . (1))
(atime . (1))
(cmin . (1))
(cnewer . (1))
(ctime . (1))
(empty . (0))
(false . (0))
(fstype . (1))
(gid . (1))
(group . (1))
(ilname . (1))
(iname . (1))
(inum . (1))
(iwholename . (1))
(iregex . (1))
(links . (1))
(lname . (1))
(mmin . (1))
(mtime . (1))
(name . (1))
(newer . (1))
(nouser . (0))
(nogroup . (0))
(path . (1))
(perm . (0))
(regex . (1))
(wholename . (1))
(size . (1))
(true . (0))
(type . (1))
(uid . (1))
(used . (1))
(user . (1))
(xtype . (nil))
;; normal options (always true)
(depth . (0))
(maxdepth . (1))
(mindepth . (1))
(mount . (0))
(noleaf . (0))
(xdev . (0))
(ignore_readdir_race . (0))
(noignore_readdir_race . (0))
;; actions
(delete . (0))
(print0 . (0))
(printf . (1))
(fprintf . (2))
(print . (0))
(fprint0 . (1))
(fprint . (1))
(ls . (0))
(fls . (1))
(prune . (0))
(quit . (0))
;; these need to be terminated with a ;
(exec . (1 find-command t))
(ok . (1 find-command t))
(execdir . (1 find-command t))
(okdir . (1 find-command t)))
"Holds details of each of the find options. The car of each
alist is the name. The cdr is minimum args, the function used
to join many occurences of the argument together, and whether or
not to leave quotes off the string (non-nil means the string will
be quoted).")
;;;###autoload
(defun find-cmd (&rest subfinds)
"Initiate the building of a find command. For exmple:
\(find-cmd '\(prune \(name \".svn\" \".git\" \".CVS\"\)\)
'\(and \(or \(name \"*.pl\" \"*.pm\" \"*.t\"\)
\(mtime \"+1\"\)\)
\(fstype \"nfs\" \"ufs\"\)\)\)\)
`default-directory' is used as the initial search path. The
result is a string that should be ready for the command line."
(concat
"find " (shell-quote-argument (expand-file-name default-directory)) " "
(cond
((cdr subfinds)
(mapconcat 'find-to-string subfinds ""))
(t
(find-to-string (car subfinds))))))
(defun find-and (form)
"And FORMs together, so:
\(and \(mtime \"+1\"\) \(name \"something\"\)\)
will produce:
find . \\\( -mtime '+1' -and -name 'something' \\\)"
(if (< (length form) 2)
(find-to-string (car form))
(concat "\\( "
(mapconcat 'find-to-string form "-and ")
"\\) ")))
(defun find-or (form)
"Or FORMs together, so:
\(or \(mtime \"+1\"\) \(name \"something\"\)\)
will produce:
find . \\\( -mtime '+1' -or -name 'something' \\\)"
(if (< (length form) 2)
(find-to-string (car form))
(concat "\\( "
(mapconcat 'find-to-string form "-or ")
"\\) ")))
(defun find-not (form)
"Or FORMs together and prefix with a -not, so:
\(not \(mtime \"+1\"\) \(name \"something\"\)\)
will produce:
-not \\\( -mtime '+1' -or -name 'something' \\\)
If you wanted the FORMs -and(ed) together instead then this would
suffice:
\(not \(and \(mtime \"+1\"\) \(name \"something\"\)\)\)"
(concat "-not " (find-or (mapcar 'find-to-string form))))
(defun find-prune (form)
"-or together FORM(s) postfix '-prune' and then -or that with a
-true, so:
\(prune \(name \".svn\" \".git\"\)\) \(name \"*.pm\"\)
will produce (unwrapped):
\\\( \\\( \\\( -name '.svn' -or -name '.git' \\\) /
-prune -or -true \\\) -and -name '*.pm' \\\)"
(find-or
(list
(concat (find-or (mapcar 'find-to-string form)) (find-generic "prune"))
(find-generic "true"))))
(defun find-generic (option &optional oper argcount args dont-quote)
"This function allows an arbitrary string to be used as a
form. OPTION is the name of the form, OPER is the function used
to either OR or AND multiple results together. ARGCOUNT is the
minimum of args that OPTION can receive and ARGS are the
arguments for OPTION."
(when (and (numberp argcount) (< (length args) argcount))
(error "'%s' needs at least %d arguments" option argcount))
(let ((oper (or oper 'find-or)))
(if (and args (length args))
(funcall oper (mapcar (lambda (x)
(concat "-" option
(if dont-quote
(concat " " x " ")
(concat " "
(shell-quote-argument x)
" "))))
args))
(concat "-" option " "))))
(defun find-command (form)
"For each item in FORM add a terminating semi-colon and turn
them into valid switches. The result is -and(ed) together."
(find-and (mapcar (lambda (x)
(concat (find-to-string x) "\\; "))
form)))
(defun find-to-string (form)
"Parse FORM to produce a set of valid find arguments."
(cond
((stringp form)
form)
((consp form)
(let ((option (cdr (assoc (car form) find-constituents))))
(cond
((and (symbolp option) (fboundp option))
(funcall option (cdr form)))
((consp option)
(let ((option (symbol-name (car form)))
(argcnt (car option))
(oper (cadr option))
(dont-quote (car (cddr option))))
(find-to-string
(find-generic option oper argcnt (cdr form) dont-quote))))
(t
(error "Sorry I don't know how to handle '%s'" (car form))))))))
(provide 'find-cmd)
;; arch-tag: 9687fd9e-4e90-4022-864a-f904526e2046
;;; find-cmd.el ends here

View file

@ -1,167 +0,0 @@
;;; flymake-cursor.el --- displays flymake error msg in minibuffer after delay
;;
;; Author : ??
;; origin : http://paste.lisp.org/display/60617,1/raw
;; Maintainer : Dino Chiesa <dpchiesa@hotmail.com>
;; : Donald Curtis <dcurtis@milkbox.net>
;; Created : May 2011
;; Modified : December 2012
;; Version : 0.1.5
;; Keywords : languages mode flymake
;; X-URL : http://www.emacswiki.org/emacs/flymake-cursor.el
;; Last-saved : <2012-Dec-20 09:49:28>
;;
;; -------------------------------------------------------
;;
;; License: None. This code is in the Public Domain.
;;
;;
;; Additional functionality that makes flymake error messages appear
;; in the minibuffer when point is on a line containing a flymake
;; error. This saves having to mouse over the error, which is a
;; keyboard user's annoyance.
;; -------------------------------------------------------
;;
;; This flymake-cursor module displays the flymake error in the
;; minibuffer, after a short delay. It is based on code I found roaming
;; around on the net, unsigned and unattributed. I suppose it's public
;; domain, because, while there is a "License" listed in it, there
;; is no license holder, no one to own the license.
;;
;; This version is modified slightly from that code. The post-command fn
;; defined in this code does not display the message directly. Instead
;; it sets a timer, and when the timer fires, the timer event function
;; displays the message.
;;
;; The reason to do this: the error message is displayed only if the
;; user doesn't do anything, for about one second. This way, if the user
;; scrolls through a buffer and there are myriad errors, the minibuffer
;; is not constantly being updated.
;;
;; If the user moves away from the line with the flymake error message
;; before the timer expires, then no error is displayed in the minibuffer.
;;
;; I've also updated the names of the defuns. They all start with flyc now.
;;
;; To use this, include this line in your .emacs:
;;
;; ;; enhancements for displaying flymake errors
;; (require 'flymake-cursor)
;;
;; You can, of course, put that in an eval-after-load clause.
;;
;; -------------------------------------------------------
;;
;; Update 2012-03-06 by Donald Curtis
;; --
;; Added some autoload statements and the closing comment to make
;; compatible with package.el parser.
;;
;; Update 2012-12-20 by Jeremy Moore
;; --
;; Alter post-command-hook's local value via add-hook so that it plays
;; nicely with other packages.
;;
(require 'cl)
(defvar flyc--e-at-point nil
"Error at point, after last command")
(defvar flyc--e-display-timer nil
"A timer; when it fires, it displays the stored error message.")
(defun flyc/maybe-fixup-message (errore)
"pyflake is flakey if it has compile problems, this adjusts the
message to display, so there is one ;)"
(cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t)))
((null (flymake-ler-file errore))
;; normal message do your thing
(flymake-ler-text errore))
(t ;; could not compile error
(format "compile error, problem on line %s" (flymake-ler-line errore)))))
(defun flyc/show-stored-error-now ()
"Displays the stored error in the minibuffer."
(interactive)
(let ((editing-p (= (minibuffer-depth) 0)))
(if (and flyc--e-at-point editing-p)
(progn
(message "%s" (flyc/maybe-fixup-message flyc--e-at-point))
(setq flyc--e-display-timer nil)))))
(defun flyc/-get-error-at-point ()
"Gets the first flymake error on the line at point."
(let ((line-no (line-number-at-pos))
flyc-e)
(dolist (elem flymake-err-info)
(if (eq (car elem) line-no)
(setq flyc-e (car (second elem)))))
flyc-e))
;;;###autoload
(defun flyc/show-fly-error-at-point-now ()
"If the cursor is sitting on a flymake error, display
the error message in the minibuffer."
(interactive)
(if flyc--e-display-timer
(progn
(cancel-timer flyc--e-display-timer)
(setq flyc--e-display-timer nil)))
(let ((error-at-point (flyc/-get-error-at-point)))
(if error-at-point
(progn
(setq flyc--e-at-point error-at-point)
(flyc/show-stored-error-now)))))
;;;###autoload
(defun flyc/show-fly-error-at-point-pretty-soon ()
"If the cursor is sitting on a flymake error, grab the error,
and set a timer for \"pretty soon\". When the timer fires, the error
message will be displayed in the minibuffer.
This allows a post-command-hook to NOT cause the minibuffer to be
updated 10,000 times as a user scrolls through a buffer
quickly. Only when the user pauses on a line for more than a
second, does the flymake error message (if any) get displayed.
"
(if flyc--e-display-timer
(cancel-timer flyc--e-display-timer))
(let ((error-at-point (flyc/-get-error-at-point)))
(if error-at-point
(setq flyc--e-at-point error-at-point
flyc--e-display-timer
(run-at-time "0.9 sec" nil 'flyc/show-stored-error-now))
(setq flyc--e-at-point nil
flyc--e-display-timer nil))))
;;;###autoload
(eval-after-load "flymake"
'(progn
(defadvice flymake-goto-next-error (after flyc/display-message-1 activate compile)
"Display the error in the mini-buffer rather than having to mouse over it"
(flyc/show-fly-error-at-point-now))
(defadvice flymake-goto-prev-error (after flyc/display-message-2 activate compile)
"Display the error in the mini-buffer rather than having to mouse over it"
(flyc/show-fly-error-at-point-now))
(defadvice flymake-mode (before flyc/post-command-fn activate compile)
"Add functionality to the post command hook so that if the
cursor is sitting on a flymake error the error information is
displayed in the minibuffer (rather than having to mouse over
it)"
(add-hook 'post-command-hook 'flyc/show-fly-error-at-point-pretty-soon t t))))
(provide 'flymake-cursor)
;;; flymake-cursor.el ends here

View file

@ -1,98 +0,0 @@
;;; go-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (go-download-play godoc gofmt-before-save go-mode)
;;;;;; "go-mode" "go-mode.el" (21514 38760 682820 85000))
;;; Generated autoloads from go-mode.el
(autoload 'go-mode "go-mode" "\
Major mode for editing Go source text.
This mode provides (not just) basic editing capabilities for
working with Go code. It offers almost complete syntax
highlighting, indentation that is almost identical to gofmt and
proper parsing of the buffer content to allow features such as
navigation by function, manipulation of comments or detection of
strings.
In addition to these core features, it offers various features to
help with writing Go code. You can directly run buffer content
through gofmt, read godoc documentation from within Emacs, modify
and clean up the list of package imports or interact with the
Playground (uploading and downloading pastes).
The following extra functions are defined:
- `gofmt'
- `godoc'
- `go-import-add'
- `go-remove-unused-imports'
- `go-goto-imports'
- `go-play-buffer' and `go-play-region'
- `go-download-play'
- `godef-describe' and `godef-jump'
- `go-coverage'
If you want to automatically run `gofmt' before saving a file,
add the following hook to your emacs configuration:
\(add-hook 'before-save-hook #'gofmt-before-save)
If you want to use `godef-jump' instead of etags (or similar),
consider binding godef-jump to `M-.', which is the default key
for `find-tag':
\(add-hook 'go-mode-hook (lambda ()
(local-set-key (kbd \"M-.\") #'godef-jump)))
Please note that godef is an external dependency. You can install
it with
go get github.com/rogpeppe/godef
If you're looking for even more integration with Go, namely
on-the-fly syntax checking, auto-completion and snippets, it is
recommended that you look at flycheck
\(see URL `https://github.com/flycheck/flycheck') or flymake in combination
with goflymake (see URL `https://github.com/dougm/goflymake'), gocode
\(see URL `https://github.com/nsf/gocode'), go-eldoc
\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go
\(see URL `https://github.com/dominikh/yasnippet-go')
\(fn)" t nil)
(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode))
(autoload 'gofmt-before-save "go-mode" "\
Add this to .emacs to run gofmt on the current buffer when saving:
(add-hook 'before-save-hook 'gofmt-before-save).
Note that this will cause go-mode to get loaded the first time
you save any file, kind of defeating the point of autoloading.
\(fn)" t nil)
(autoload 'godoc "go-mode" "\
Show Go documentation for a query, much like M-x man.
\(fn QUERY)" t nil)
(autoload 'go-download-play "go-mode" "\
Downloads a paste from the playground and inserts it in a Go
buffer. Tries to look for a URL at point.
\(fn URL)" t nil)
;;;***
(provide 'go-mode-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; go-mode-autoloads.el ends here

File diff suppressed because it is too large Load diff

@ -1 +0,0 @@
Subproject commit 35f6826e435c3004dabf134d0f2ae2f31ea7b6a2

View file

@ -1,242 +0,0 @@
;;; ssass-mode.el --- Edit Sass without a Turing Machine
;; Copyright 2017 Adam Niederer
;; Author: Adam Niederer <adam.niederer@gmail.com>
;; URL: http://github.com/AdamNiederer/ssass-mode
;; Version: 0.2.0
;; Keywords: languages sass
;; Package-Requires: ((emacs "24.3"))
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This mode is a clone of sass-mode which works in mmm-mode and doesn't
;; indent things as eagerly. Syntax highlighting is provided with
;; `font-lock-mode'.
;;
;; Exported names start with "ssass-"; private names start with
;; "ssass--".
;;; Code:
(defgroup ssass nil
"Major mode for Sass files"
:prefix "ssass-"
:group 'languages
:link '(url-link :tag "Github" "https://github.com/AdamNiederer/ssass-mode")
:link '(emacs-commentary-link :tag "Commentary" "ssass-mode"))
(defconst ssass-id-regex
"#[a-z][A-Za-z0-9\-]+")
(defconst ssass-class-regex
"\\.[a-z][A-Za-z0-9\-]+")
(defconst ssass-pseudoselector-regex
"::?[A-Za-z0-9\-]+")
(defconst ssass-key-regex
"^\s+[a-z\-]+:")
(defconst ssass-directive-noindent-regex
"@\\(include\\|extend\\|import\\|warn\\|debug\\|error\\)"
"Matches all directives which do not require indentation.")
(defconst ssass-variable-regex
"\$[A-Za-z0-9\-]+")
(defconst ssass-variable-assignment-regex
(concat ssass-variable-regex ":"))
(defconst ssass-builtin-regex
"@[A-Za-z]+")
(defconst ssass-comment-regex
"^\s+/[/*].*") ; TODO: Make better or use syntax table
(defconst ssass-function-regex
"\\([A-Za-z\-]+?\\)\\((.*)\\)")
(defconst ssass-keywords
'("and" "or" "not" "in" "from" "to" "through"))
(defconst ssass-control-directives
'("@if" "@else" "@each" "@for"))
(defconst ssass-function-directives
'("@function" "@return"))
(defconst ssass-mixin-directives
'("@mixin" "@include"))
(defconst ssass-constants
'("true" "false" "null"))
(defconst ssass-bang-regex
"![a-z][A-Za-z0-9]+")
(defcustom ssass-tab-width 2
"Tab width for ssass-mode."
:group 'ssass
:type 'integer)
(defcustom ssass-indent-blanks t
"Whether to indent blank lines."
:group 'ssass
:type 'boolean)
(defcustom ssass-compiler "sassc"
"Sass compiler for `ssass-eval-region' and `ssass-eval-buffer'."
:group 'ssass
:type 'string)
(defcustom ssass-opt "--sass"
"Options for `ssass-compiler'.
Use --sass for sassc, and --indented-syntax for node-sass."
:group 'ssass
:type 'string)
(defcustom ssass-color-keys nil
"(TODO) Whether to color proprty names."
:group 'ssass
:type 'boolean)
(defconst ssass-font-lock-keywords
`((,ssass-id-regex . (0 font-lock-keyword-face))
(,ssass-class-regex . (0 font-lock-type-face))
(,ssass-key-regex . (0 font-lock-variable-name-face))
(,ssass-function-regex . (1 font-lock-function-name-face))
(,ssass-builtin-regex . (0 font-lock-builtin-face))
(,ssass-pseudoselector-regex . (0 font-lock-function-name-face))
(,ssass-variable-regex . (0 font-lock-variable-name-face))
(,ssass-bang-regex . (0 font-lock-warning-face))
(,(regexp-opt ssass-keywords 'words) . font-lock-keyword-face)
(,(regexp-opt ssass-control-directives 'words) . font-lock-keyword-face)
(,(regexp-opt ssass-function-directives 'words) . font-lock-keyword-face)
(,(regexp-opt ssass-constants 'words) . font-lock-constant-face))
"List of Font Lock keywords.")
(defvar ssass-mode-map
(let ((map (make-keymap)))
(define-key map (kbd "<backtab>") 'ssass-dedent)
(define-key map (kbd "C-c C-c") 'ssass-eval-buffer)
(define-key map (kbd "C-c C-r") 'ssass-eval-region)
map)
"Keymap for ssass-mode.")
(defun ssass--selector-p (line)
"Return whether LINE is a selector."
(not (or (string-empty-p line)
(string-match-p ssass-key-regex line)
(string-match-p ssass-variable-assignment-regex line)
(string-match-p ssass-directive-noindent-regex line)
(string-match-p ssass-comment-regex line))))
(defun ssass--goto-last-anchor-line ()
"Move point to the line of the last selector, or the beginning of the buffer."
(forward-line -1)
(while (not (or (equal (point-min) (point-at-bol))
(ssass--selector-p (buffer-substring (point-at-bol) (point-at-eol)))))
(forward-line -1)))
(defun ssass--last-anchor-line-indent-level ()
"Return the number of spaces indenting the line of the last selector."
(save-excursion
(ssass--goto-last-anchor-line)
(ssass--indent-level)))
(defun ssass--indent-level ()
"Return the number of spaces indenting the current line."
(- (save-excursion
(back-to-indentation)
(current-column))
(save-excursion
(beginning-of-line)
(current-column))))
(defun ssass--whitespace-p (line)
"Return whether the line at offset from point LINE consists solely of whitespace."
(save-excursion
(forward-line line)
(string-match-p "^[[:space:]]*$" (buffer-substring (point-at-bol) (point-at-eol)))))
(defun ssass--comma-before-p ()
"Return whether the previous line has a comma at its end."
(save-excursion
(forward-line -1)
(string-match-p ",\\s-*$" (buffer-substring (point-at-bol) (point-at-eol)))))
(defun ssass--no-anchor-line-p ()
"Return whether there is no proper selector or keyword above this line."
(save-excursion
(ssass--goto-last-anchor-line)
(not (ssass--selector-p (buffer-substring (point-at-bol) (point-at-eol))))))
(defun ssass-indent ()
"Indent the current line."
(interactive)
(indent-line-to
(cond
((and (not ssass-indent-blanks) (ssass--whitespace-p 0)) 0)
((ssass--whitespace-p -1) 0)
((ssass--no-anchor-line-p) 0)
((ssass--comma-before-p) (ssass--last-anchor-line-indent-level))
(t (+ ssass-tab-width (ssass--last-anchor-line-indent-level))))))
(defun ssass-dedent ()
"Remove one level of indentation from the current line."
(interactive)
(indent-line-to (max 0 (- (ssass--indent-level) ssass-tab-width))))
(defun ssass-eval-file (&optional filename)
"Run the given file through sass, and display the output in another window.
If FILENAME is nil, it will open the current buffer's file"
(interactive)
(when (buffer-live-p (get-buffer "*sass*"))
(kill-buffer "*sass*"))
(start-process "sass" "*sass*" ssass-compiler ssass-opt (or filename (buffer-file-name)))
(switch-to-buffer-other-window "*sass*")
(special-mode))
(defun ssass-eval-region (beg end)
"Run the region from BEG to END through sass, and display the output in another window."
(interactive "r")
(let ((tmp-file (make-temp-file "sass-eval" nil ".sass")))
(write-region beg end tmp-file nil nil nil nil)
(ssass-eval-file tmp-file)
(delete-file tmp-file)) )
(defun ssass-eval-buffer ()
"Run the current buffer through sass, and display the output in another window."
(interactive)
(ssass-eval-region (point-min) (point-max)))
;;;###autoload
(define-derived-mode ssass-mode prog-mode "Ssass"
"Major mode for Sass"
(setq-local electric-indent-mode nil)
(setq-local comment-start "//")
(setq-local comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
(set (make-local-variable 'tab-width) ssass-tab-width)
(set (make-local-variable 'indent-line-function) 'ssass-indent)
(font-lock-add-keywords nil ssass-font-lock-keywords)
(modify-syntax-entry ?/ ". 124" ssass-mode-syntax-table)
(modify-syntax-entry ?* ". 23b" ssass-mode-syntax-table)
(modify-syntax-entry ?\n ">" ssass-mode-syntax-table))
(provide 'ssass-mode)
;;; ssass-mode.el ends here

View file

@ -1,131 +0,0 @@
;;; vue-html-mode.el --- Major mode for editing Vue.js templates
;; Copyright 2016, 2017 Adam Niederer
;; Author: Adam Niederer <adam.niederer@gmail.com>
;; URL: http://github.com/AdamNiederer/vue-html-mode
;; Version: 0.2.0
;; Keywords: languages vue template
;; Package-Requires: ()
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary
;; The main features of this mode are syntax highlighting (enabled with
;; `font-lock-mode' or `global-font-lock-mode'), and html-mode
;; integration
;;
;; Exported names start with "vue-html-"; private names start with
;; "vue-html--".
;;
;; TODO: Chained filters, possible code folding with overlays and colors
;;; Code:
(defgroup vue-html nil
"Major mode for vue template files"
:prefix "vue-html-"
:group 'languages
:link '(url-link :tag "Github" "https://github.com/AdamNiederer/vue-html-mode")
:link '(emacs-commentary-link :tag "Commentary" "vue-html-mode"))
(defconst vue-html-complex-interp-regex
"\\({{\\)\\([^{].*?\\)?\\(|\\) *\\(.*?\\)(.*) *\\(}}\\)")
(defconst vue-html-filter-interp-regex
"\\({{\\)\\([^{].*?\\)?\\(|\\) *\\([^\(\)]*?\\) *\\(}}\\)")
(defconst vue-html-simple-interp-regex
"\\({{\\)\\(?:[^{].*?\\)?\\(}}\\)")
(defconst vue-html-shorthand-regex
"\\s +\\([@:]\\)\\([A-z0-9-.]+\\)=.*?")
(defconst vue-html-directive-regex
"\\b\\(v-[A-Za-z0-9-.]+\\)\\(:[A-z.]\\)?")
(defconst vue-html-keyword-regex
"\\(v-\\(?:for\\|if\\|else-if\\|else\\|once\\)\\)[^-.A-Za-z0-9]")
(defcustom vue-html-tab-width 2
"Tab width for vue-html-mode."
:group 'vue-html
:type 'integer)
(defcustom vue-html-extra-indent 0
"The number of columns added to every line's indentation."
:group 'vue-html
:type 'integer)
(defcustom vue-html-color-interpolations nil
"Whether to color the body of variable interpolations the same as delimiters.
Does not affect the colors of filters and their arguments."
:group 'vue-html
:type 'boolean)
(defconst vue-html-color-interpolations-font-lock-keywords
`((,vue-html-simple-interp-regex . (0 font-lock-variable-name-face t))
(,vue-html-filter-interp-regex . (2 font-lock-variable-name-face t))
(,vue-html-complex-interp-regex . (2 font-lock-variable-name-face t)))
"List of Font Lock rules applied if `vue-html-color-interpolations' is non-nil.")
(defconst vue-html-font-lock-keywords
`((,vue-html-simple-interp-regex . (1 font-lock-variable-name-face t))
(,vue-html-simple-interp-regex . (2 font-lock-variable-name-face t))
(,vue-html-filter-interp-regex . (1 font-lock-variable-name-face t))
(,vue-html-filter-interp-regex . (3 font-lock-function-name-face t))
(,vue-html-filter-interp-regex . (4 font-lock-function-name-face t))
(,vue-html-filter-interp-regex . (5 font-lock-variable-name-face t))
(,vue-html-complex-interp-regex . (1 font-lock-variable-name-face t))
(,vue-html-complex-interp-regex . (3 font-lock-function-name-face t))
(,vue-html-complex-interp-regex . (4 font-lock-function-name-face t))
(,vue-html-complex-interp-regex . (5 font-lock-variable-name-face t))
(,vue-html-directive-regex . (1 font-lock-builtin-face t))
(,vue-html-shorthand-regex . (1 font-lock-builtin-face t))
(,vue-html-shorthand-regex . (2 font-lock-variable-name-face t))
(,vue-html-keyword-regex . (1 font-lock-keyword-face t)))
"List of Font Lock keywords which are applied regardless of settings.")
(defvar vue-html-mode-map
(let ((map (make-keymap)))
map)
"Keymap for vue-html-mode.")
(defun vue-html-last-line-p ()
"Return whether point is on the last line in the buffer."
(save-excursion (= (line-number-at-pos) (line-number-at-pos (point-max)))))
(defun vue-html-line-empty-p ()
"Return whether point is on an empty line."
(string-match-p "^\s*$" (buffer-substring (point-at-bol) (point-at-eol))))
(defun vue-html-indent ()
"Indent the line according to `vue-html-tab-width' and `vue-html-extra-indent'."
(cond
((= 1 (line-number-at-pos)) (indent-line-to vue-html-extra-indent))
((and (vue-html-last-line-p) (vue-html-line-empty-p)) (indent-line-to 0))
(t (sgml-indent-line))))
;;;###autoload
(define-derived-mode vue-html-mode html-mode "vue-html"
"Major mode for Vue.js templates."
(setq tab-width vue-html-tab-width)
(setq indent-line-function #'vue-html-indent)
(font-lock-add-keywords nil vue-html-font-lock-keywords)
(when vue-html-color-interpolations
(font-lock-add-keywords nil vue-html-color-interpolations-font-lock-keywords)))
(provide 'vue-html-mode)
;;; vue-html-mode.el ends here