Compare commits

...

14 Commits

8 changed files with 645 additions and 629 deletions

2
.gitignore vendored
View File

@ -70,3 +70,5 @@ projects
/eshell/
/persist/
/lsp-cache/
/mastodon.plstore
/eln-cache/

15
LICENSE
View File

@ -1,3 +1,18 @@
Note regarding init.el and config.org: There is some code in the configuration
file that is heavily inspired (though not necessarily copied) from other peoples
configuration.
Note regarding packages/ts-mode.el: This file is not written by myself but by
Joachim Mathes and released under the GPLv3 by him. It is kept in this
repository since it is not available in any package archive.
Note regarding packages/org-quick-capture.el: The main code was grabbed from
Reddit and published there by u/lebitso and an anonymous commenter (URLs in
file). It was published without a license but I doubt that it is relevant given
the extreme simplicity of the code.
-------------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Binary file not shown.

View File

@ -424,9 +424,8 @@ Source: [[https://github.com/greduan/emacs-theme-gruvbox][Github: greduan/emacs-
#+begin_src emacs-lisp
(use-package gruvbox-theme
:disabled t
:config
(load-theme 'gruvbox-light-medium t))
(load-theme 'gruvbox-light-hard t))
#+end_src
Installing and enabling Modus themes. /Disabled in favor of the Doom themes./
@ -449,6 +448,7 @@ Installing and enabling Doom themes.
#+begin_src emacs-lisp
(use-package doom-themes
:disabled t
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
@ -457,10 +457,34 @@ Installing and enabling Doom themes.
(doom-themes-org-config))
#+end_src
Installing and enabling ef-themes.
#+begin_src emacs-lisp
(use-package ef-themes
:disabled t
:init
(setq ef-themes-to-toggle '(ef-light ef-dark))
(setq ef-themes-mixed-fonts t
ef-themes-variable-pitch-ui t)
(setq ef-themes-headings
'((0 . (variable-pitch light 1.9))
(1 . (variable-pitch light 1.8))
(2 . (variable-pitch regular 1.7))
(3 . (variable-pitch regular 1.6))
(4 . (variable-pitch regular 1.5))
(5 . (variable-pitch 1.4))
(6 . (variable-pitch 1.3))
(7 . (variable-pitch 1.2))
(t . (variable-pitch 1.1))))
:config
(load-theme 'ef-light t))
#+end_src
Add a slight transparency to the frames. Code provided by David Wilson / System Crafters [[https://github.com/daviwil/emacs-from-scratch/blob/master/Emacs.org][Emacs from Scratch]] video series.
#+begin_src emacs-lisp
(setq mmk2410/frame-transparency '(90 . 90))
(setq mmk2410/frame-transparency '(95 . 95))
(set-frame-parameter (selected-frame) 'alpha mmk2410/frame-transparency)
(add-to-list 'default-frame-alist `(alpha . ,mmk2410/frame-transparency))
@ -471,14 +495,15 @@ Add a slight transparency to the frames. Code provided by David Wilson / System
During the last weeks I got used to using a light theme during daytime and a dark theme during nighttime. Luckily the themes based on Atom One are to my liking and the doom package provides a dark and light variant. One thing that was difficult with Emacs was actually switching theme since it involved disabling all current ones (for some reason on one machine there are two enabled while on the other machine its only one) and then loading the correct one. These functions try to make that process easier, at least for now. The long-term goal is to automatically change the theme based on the current system-wide setting.
#+begin_src emacs-lisp
(setq mmk2410/theme-night 'doom-one)
(setq mmk2410/theme-day 'doom-one-light)
(setq mmk2410/theme-night 'gruvbox-dark-hard)
(setq mmk2410/theme-day 'gruvbox-light-hard)
(defun mmk2410/switch-theme (theme)
(mapcar 'disable-theme custom-enabled-themes)
(load-theme theme t)
(mmk2410/org-font-adjust-headlines)
(mmk2410/org-font-adjust-variable-pitch))
(unless (string-prefix-p "ef-" theme)
(mmk2410/org-font-adjust-headlines)
(mmk2410/org-font-adjust-variable-pitch)))
(defun mmk2410/switch-theme-night ()
(interactive)
@ -567,6 +592,7 @@ Source: [[https://github.com/emacs-evil/evil][GitHub: emacs-evil/evil]]
#+begin_src emacs-lisp
(use-package evil
:disabled t
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
@ -582,6 +608,7 @@ An even better integration may be achieved when additionall using the [[https://
#+begin_src emacs-lisp
(use-package evil-collection
:disabled t
:after evil
:config (evil-collection-init))
#+end_src
@ -590,6 +617,7 @@ Additional I like to press =jk= for exiting normal mode, using [[https://github.
#+begin_src emacs-lisp
(use-package key-chord
:disabled t
:config
(key-chord-define evil-insert-state-map "jk" 'evil-normal-state)
(key-chord-mode 1))
@ -727,6 +755,7 @@ Source: [[https://github.com/Alexander-Miller/treemacs][Alexander-Miller/treemac
("C-c b M-f" . treemacs-find-tag)))
(use-package treemacs-evil
:disabled t
:after (treemacs evil))
#+end_src
@ -901,7 +930,8 @@ I like to have larger headlines in Org for better identifying them. The configur
(set-face-attribute (car face) nil :font "Open Sans" :weight 'bold :height (cdr face))))
(with-eval-after-load 'org
(mmk2410/org-font-adjust-headlines))
(unless (string-prefix-p "ef-" (format "%s" (car custom-enabled-themes)))
(mmk2410/org-font-adjust-headlines)))
#+end_src
When using a variable-pitch font this also applies to stuff like code blocks. The following block resets this change for these unwanted faces.
@ -916,10 +946,12 @@ When using a variable-pitch font this also applies to stuff like code blocks. Th
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch))
(with-eval-after-load 'org
(mmk2410/org-font-adjust-variable-pitch))
(unless (string-prefix-p "ef-" (format "%s" (car custom-enabled-themes)))
(mmk2410/org-font-adjust-variable-pitch)))
#+end_src
** Org Superstar Mode
@ -1067,10 +1099,16 @@ Forbid closing of todos with open subtasks.
Set org agenda files.
#+begin_src emacs-lisp
(setq org-agenda-files (list "~/org/")
org-agenda-text-search-extra-files (list "~/org/archive/"
"~/org/roam/"
"~/org/articles/"))
(setq org-agenda-files
(list
"~/org/"
"~/org/personal-computer/"
"~/org/projects/"))
(setq org-agenda-text-search-extra-files
(list "~/org/archive/"
"~/org/roam/"
"~/org/articles/"))
#+end_src
Open org-agenda in current window.
@ -1084,19 +1122,15 @@ Define org-capture templates.
#+begin_src emacs-lisp
(setq org-capture-templates
'(("t" "Normal task" entry (file "~/org/inbox.org")
"* TODO %?\n :PROPERTIES:\n :CREATED: %U\n :END:")
("w" "Work task" entry (file "~/org/work.inbox.org")
"* TODO %?\n :PROPERTIES:\n :CREATED: %U\n :END:")
("e" "E-Mail needing a reply" entry (file "~/org/emails.org")
"* TODO Reply: %a\n :PROPERTIES:\n :CREATED: %U\n :END:"
"* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:")
("e" "E-Mail needing a reply" entry (file "~/org/inbox.org")
"* TODO Reply: %a\n:PROPERTIES:\n:CREATED: %U\n:END:"
:immediate-finish t)
("p" "org-protocol-capture" entry (file "~/org/inbox.org")
"* TODO [[%:link][%:description]]\n :PROPERTIES:\n :CREATED: %U\n :END:\n\n %i"
"* TODO [[%:link][%:description]]\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n%i"
:immediate-finish t)
("s" "Event" entry (file "~/org/events.org")
"* SOMEDAY %? %^G\n SCHEDULED: %^T\n :PROPERTIES:\n :CREATED: %U\n :END:")
("r" "Reading todo" entry (file "~/org/reading.org")
"* TODO %^L %^G\n :PROPERTIES:\n :CREATED: %U\n :END:\n")))
("r" "Reading todo" entry (file "~/org/read-review.org")
"* TODO %^L %^G\n:PROPERTIES:\n:CREATED: %U\n:END:\n")))
#+end_src
Configure refiling TODOs.
@ -1172,6 +1206,21 @@ Finally define the org-agenda display using [[https://github.com/alphapapa/org-s
(:name "Someday" :todo "SOMEDAY" :scheduled future :order 101))))))))))
#+end_src
** Quick Capture from everywhere
Given the fact that I run Emacs using Emacsclient all the time I though it would be quite helpful to have the ability to capture a to-do from everywhere, e.g. a sudden thought crossing my mind while developing photos or browsing the web. Thanks to the help of an [[https://www.reddit.com/r/emacs/comments/74gkeq/system_wide_org_capture][Reddit post]] by [[https://www.reddit.com/user/lebitso][u/lebitso]] I was able to achieve this goal and I put the code in an extra package that is loaded here.
#+begin_src emacs-lisp
(use-package org-quick-capture
:load-path "packages/")
#+end_src
To use this, I wrote a small shell script that I'm assigning a keyboard shortcut in my window manager / desktop environment. The shell script essentially runs the following command:
#+begin_src sh
emacsclient -c -F '(quote (name . "capture"))' -e '(activate-capture-frame)'
#+end_src
** Automatic UUID creation
I am currently exploring the option in Org mode to export a file (or some entries) to an ics-file which I can then in turn import into my calendar. For reliably creating (and most importantly: updating) entries it is necessary that each one has an unique ID. To create a ID for the current entry I could just run =M-x org-id-get-create= and for an entire file execute the following Emacs Lisp ~(org-map-entries 'org-id-get-create)~. Of course this is not an ideal solution. But adding this s-expression to ~org-mode-hook~ would create IDs in all Org file I edit which I also don't like. Since the amount of files I do want the automatic creation is (currently) not that large it is OK for me to do some work on my own, at least if it is only a one time setup.
@ -1338,15 +1387,30 @@ Source: [[https://www.orgroam.com][orgroam.com]]
(direction . right)
(window-width . 0.33)
(window-height . fit-window-to-buffer)))
(setq org-roam-dailies-directory "daily/")
(setq org-roam-dailies-capture-templates
'(("c" "clock" entry "* %<%H:%M> %?"
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))
("n" "note" entry "* %?"
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))
("t" "todo" entry "* TODO %?"
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
(require 'org-roam-protocol)
(require 'org-roam-dailies)
(org-roam-db-autosync-mode)
:bind (("C-c r f" . org-roam-node-find)
("C-c r i" . org-roam-node-insert)
("C-c r b" . org-roam-buffer-toggle)
("C-c r c" . org-roam-capture)
("C-c r g" . org-roam-graph)
:map org-mode-map
("C-M-i" . completion-at-point)
:map org-roam-mode-map
("[mouse-1]" . #'org-roam-visit-thing)))
("[mouse-1]" . #'org-roam-visit-thing)
:map org-roam-dailies-map
("Y" . org-roam-dailies-capture-yesterday)
("T" . org-roam-dailies-capture-tomorrow))
:bind-keymap ("C-c r d" . org-roam-dailies-map))
#+end_src
** Org Roam Bibtex
@ -1518,6 +1582,7 @@ Source: [[https://www.flycheck.org][flycheck.org]]
#+begin_src emacs-lisp
(use-package flycheck
:config (setq-default flycheck-emacs-lisp-load-path 'inherit)
:init (global-flycheck-mode))
#+end_src
@ -1663,19 +1728,21 @@ Source: [[https://github.com/yoshiki/yaml-mode][GitHub: yoshiki/yaml-mode]]
("\\.yml\\'" . yaml-mode)))
#+end_src
** MoinMoin
MoinMoin mode for Emacs.
** TypoScript
Source: [[https://moinmo.in/action/raw/EmacsForMoinMoin/MoinMoinMode?action=raw][MoinMoin wiki: EmacsForMoinMoin]]
TypoScript major mode for Emacs.
Original Source: [[https://www.emacswiki.org/emacs/ts-mode.el][EmacsWiki: ts-mode.el]]
#+begin_src emacs-lisp
(use-package moinmoin-mode
:load-path "lisp/moinmoin-mode/"
:mode "\\.wiki\\'"
:commands (moinmoin-mode))
(use-package ts-mode
:load-path "packags/"
:mode (("\\.typoscript\\'" . ts-mode)
("\\.tsconfig\\'" . ts-mode)))
#+end_src
* Emacs Multimedia System (EMMS)
For notes, tasks, writing, and countless other things there is org-mode.
@ -1853,7 +1920,7 @@ Using this function I can now define a org-capture template for my purpose.
#+begin_src emacs-lisp
(add-to-list 'org-capture-templates
'("a" "RSS Article" entry (file "~/org/reading.org")
'("a" "RSS Article" entry (file "~/org/read-review.org")
"* TODO %(elfeed-feed-title (mmk2410/org-capture-elfeed-entry-props 'elfeed-entry-feed)): [[%(mmk2410/org-capture-elfeed-entry-props 'elfeed-entry-link)][%(mmk2410/org-capture-elfeed-entry-props 'elfeed-entry-title)]]\n :PROPERTIES:\n :CREATED: %U\n :END:\n"
:immediate-finish t))
#+end_src
@ -1881,6 +1948,19 @@ Source: [[https://github.com/fasheng/elfeed-protocol][GitHub: fasheng/elfeed-pro
(elfeed-protocol-enable))
#+end_src
* Mastodon
Emacs client for Mastodon.
[[https://codeberg.org/martianh/mastodon.el][Codeberg: martianh/mastodon.el]]
#+begin_src emacs-lisp
(use-package mastodon
:config
(setq mastodon-instance-url "https://fosstodon.org"
mastodon-active-user "mmk2410"))
#+end_src
* mu4e
Managing e-mails is maybe one of the most critical tasks in my life. Over the last years I tried countless different clients, including the famous (neo)mutt, KMail, and Thunderbird. But it seems that I always go back to one specific: mu4e. Maybe because it is integrated in Emacs and Org-mode, maybe because I like using a keyboard-focused client and that's where I end. I don't now. But what I know is: I enjoy using it!
@ -1900,11 +1980,14 @@ Not all distributions that I use have a enough up-to-date package of mu/maildir-
(defun mmk2410/mu4e-load-path ()
(let* ((mu4e-site-lisp-path "/share/emacs/site-lisp/mu4e")
(mu4e-load-path-usr (concat "/usr" mu4e-site-lisp-path))
(mu4e-load-path-usr-local (concat "/usr/local" mu4e-site-lisp-path)))
(cond ((file-directory-p mu4e-load-path-usr)
mu4e-load-path-usr)
(mu4e-load-path-usr-local (concat "/usr/local" mu4e-site-lisp-path))
(mu4e-load-path-nix (concat (getenv "HOME") "/.nix-profile" mu4e-site-lisp-path)))
(cond ((file-directory-p mu4e-load-path-nix)
mu4e-load-path-nix)
((file-directory-p mu4e-load-path-usr-local)
mu4e-load-path-usr-local)
((file-directory-p mu4e-load-path-usr)
mu4e-load-path-usr-local)
(t (error "mu4e not found!"))))))
#+end_src

View File

@ -1,589 +0,0 @@
;;; Use raw text to fetch this code, see EmacsForMoinMoin for tutorial and discussion.
;;; Download link: http://moinmo.in/EmacsForMoinMoin/MoinMoinMode?action=raw
;;; moinmoin-mode.el --- a major mode to edit MoinMoin wiki pages
;; Written by ASK, distributed under GPL
;; Filename: moinmoin-mode.el
;; Keywords: moinmoin, wiki
;; Description: a major mode to edit MoinMoin wiki pages
;; Compatibility: GNU Emacs 22.0.50.1 (probably others)
;; Last modified: 2006-04-15
;; This file is NOT part of GNU Emacs.
;;; Definition of font faces
(defgroup moinmoin nil
"Major mode for MoinMoin wiki pages"
:prefix "moinmoin-")
(defface moinmoin-h5 '((t (:foreground "tan3" :slant italic)))
"Face name to use for 5-level headings in moinmoin"
:group 'moinmoin)
(defface moinmoin-h4 '((t (:inherit moinmoin-h5 :slant normal :foreground "tan4")))
"Face name to use for 4-level headings in moinmoin"
:group 'moinmoin)
(defface moinmoin-h3 '((t (:inherit moinmoin-h4 :weight bold)))
"Face name to use for 3-level headings in moinmoin"
:group 'moinmoin)
(defface moinmoin-h2 '((t (:inherit moinmoin-h3 :height 1.2)))
"Face name to use for 3-level headings in moinmoin"
:group 'moinmoin)
(defface moinmoin-h1 '((t (:inherit moinmoin-h2 :height 1.4)))
"Face name to use for 3-level headings in moinmoin"
:group 'moinmoin)
(defface moinmoin-smiley '((t (:foreground "green4" :weight bold)))
"Face name to use smileys in moinmoin"
:group 'moinmoin)
(defface moinmoin-table-separator '((t (:foreground "salmon" :weight bold)))
"Face name to use for separation of columns in tables of moinmoin"
:group 'moinmoin)
(defface moinmoin-table-pi '((t (:foreground "plum3")))
"Face name to use for processing instructions in tables of moinmoin"
:group 'moinmoin)
(defface moinmoin-anchor '((t (:foreground "tan3" :height 0.8)))
"Face name to use for anchors (targets) in moinmoin"
:group 'moinmoin)
(defface moinmoin-anchor-ref-id '((t (:foreground "blue2" :height 0.8 :underline t)))
"Face name to use for id in anchor reference in moinmoin"
:group 'moinmoin)
(defface moinmoin-anchor-ref-title '((t (:foreground "blue4" :underline t)))
"Face name to use for title in anchors reference in moinmoin"
:group 'moinmoin)
(defface moinmoin-macro-name '((t (:foreground "plum3")))
"Face name to use for names of macros in moinmoin"
:group 'moinmoin)
(defface moinmoin-macro-parameters '((t (:foreground "plum4")))
"Face name to use for parameters of macros in moinmoin"
:group 'moinmoin)
(defface moinmoin-item '((t (:foreground "brown" :weight bold)))
"Face name to use for items in lists in moinmoin"
:group 'moinmoin)
(defface moinmoin-item-2 '((t (:foreground "brown")))
"Face name to use for second-level items in moinmoin"
:group 'moinmoin)
(defface moinmoin-blockquote-indent '((t (:background "aquamarine1")))
"Face name to use for blockquote indentation in moinmoin"
:group 'moinmoin)
(defface moinmoin-blockquote-text '((t (:foreground "aquamarine4")))
"Face name to use for blockquote text in moinmoin"
:group 'moinmoin)
(defface moinmoin-code '((t (:foreground "purple4")))
"Face name to use for code inside braces in moinmoin"
:group 'moinmoin)
(defface moinmoin-code-braces '((t (:foreground "plum3")))
"Face name to use for baces which delimit code inside braces in moinmoin"
:group 'moinmoin)
(defface moinmoin-pi '((t (:foreground "plum3" :weight bold)))
"Face name to use for processing instructions in moinmoin"
:group 'moinmoin)
(defface moinmoin-comment '((t (:foreground "maroon3")))
"Face name to use for comments in moinmoin"
:group 'moinmoin)
(defface moinmoin-rule '((t (:foreground "tomato2" :weight bold)))
"Face name to use for rules in moinmoin"
:group 'moinmoin)
(defface moinmoin-ss '((t (:foreground "grey" ))) ;; try also :height 0.1
"Face name to use for syntactic sugar in moinmoin"
:group 'moinmoin)
(defface moinmoin-tt '((t (:foreground "cyan4")))
"Face name to use for typewriter text in moinmoin"
:group 'moinmoin)
(defface moinmoin-entity '((t (:foreground "grey")))
"Face name to use for HTML entities in moinmoin"
:group 'moinmoin)
(defface moinmoin-email '((t (:foreground "blue2")))
"Face name to use for emails in moinmoin"
:group 'moinmoin)
(defface moinmoin-url '((t (:foreground "blue2" :height 0.8)))
"Face name to use for URLs in moinmoin"
:group 'moinmoin)
(defface moinmoin-url-title '((t (:foreground "blue4" :underline t)))
"Face name to use for title of URL in moinmoin"
:group 'moinmoin)
(defface moinmoin-wiki-link '((t (:foreground "blue4" :weight bold)))
"Face name to use for CamelCase links in moinmoin"
:group 'moinmoin)
(defface moinmoin-inter-wiki-link '((t (:foreground "blue3" :weight bold)))
"Face name to use for inter wiki links in moinmoin"
:group 'moinmoin)
(defface moinmoin-bold '((t (:weight bold)))
"Face name to use for bold text in moinmoin"
:group 'moinmoin)
(defface moinmoin-italic '((t (:slant italic)))
"Face name to use for italic text in moinmoin"
:group 'moinmoin)
(defface moinmoin-underline '((t (:underline t)))
"Face name to use for underlined text in moinmoin"
:group 'moinmoin)
(defface moinmoin-stroke '((t (:strike-through t)))
"Face name to use for stroked text in moinmoin"
:group 'moinmoin)
(defface moinmoin-subscript '((t (:height 0.8)))
"Face name to use for subscripts in moinmoin"
:group 'moinmoin)
(defface moinmoin-superscript '((t (:height 0.8)))
"Face name to use for superscripts in moinmoin"
:group 'moinmoin)
;;; Font lock setup
(defconst moinmoin-url-prefix
"\\(?:http\\|https\\|ftp\\|nntp\\|news\\|mailto\\|telnet\\|wiki\\|file\\|irc\\|attachment\\|inline\\|drawing\\)"
"Bracketed regexp matching URL prefixes in moinmoin")
(defconst moinmoin-url-punctuation
"]\"'}|:,.)?!" ; start with ]
"Punctuation in URLs of moinmoin")
(defconst moinmoin-pi-re
"^#\\(?:format\\|refresh\\|redirect\\|deprecated\\|pragma\\|form\\|acl\\|language\\).*$"
"Regexp for processing instructions in moinmoin")
(defconst moinmoin-smiley-re
"\\(?:<:(\\|X-(\\|:)\\|:-))\\|:(\\|/!\\\\\\|{X}\\|{OK}\\|B-)\\|{2}\\|>:>\\|;-)\\|<!>\\|:o\\||-)\\|;)\\||)\\|(!)\\|:-(\\|:-)\\|{o}\\|:D\\|(./)\\|B)\\|{*}\\|:\\\|:-?\\|{i}\\|{3}\\|{1}\\|:)\\)"
"Regexp for smileys in moinmoin")
(defun moinmoin-formatted-code-matcher (bound)
"Search for formatted code
This is supposed to be bug-to-bug compatible with moinmoin-1.5.2"
(catch 'match
(while (< (point) bound)
(unless (search-forward-regexp "{{{" bound t)
(throw 'match nil))
(let ((start-brace-begin (match-beginning 0))
(start-brace-end (match-end 0))
pi-begin pi-end
code-begin code-end
end-brace-begin end-brace-end)
(unless (get-text-property start-brace-begin 'moinmoin-verbatim)
(goto-char start-brace-end)
(if (looking-at "#!.*\n")
(setq pi-begin (match-beginning 0)
pi-end (match-end 0)
code-begin (match-end 0))
(setq code-begin start-brace-end))
(goto-char code-begin)
(let ((not-first-line))
(while (looking-at
"\\(?:##.*\\|`.*?`\\|{{{.*?}}}\\|.\\)*?\\(?:\\(}}}\\)\\|\n\\)")
(goto-char (match-end 0))
(when (and (match-beginning 1) ; non-paired `}}}'
not-first-line)
(setq code-end (match-beginning 1)
end-brace-begin (match-beginning 1)
end-brace-end (match-end 1))
(set-match-data (list start-brace-begin end-brace-end
start-brace-begin start-brace-end
pi-begin pi-end
code-begin code-end
end-brace-begin end-brace-end))
(throw 'match t))
(setq not-first-line t)))
(throw 'match nil))))))
(defun moinmoin-bracketed-url-matcher (bound)
"Search for bracketed URLs"
(catch 'match
(while (< (point) bound)
(unless (search-forward-regexp
(concat "\\(\\[\\)"
"\\(" moinmoin-url-prefix "?:.*?\\) +"
"\\(.*?\\)?"
"\\(\\]\\)") bound t)
(throw 'match nil))
(unless (get-text-property (match-beginning 0) 'moinmoin-verbatim)
(throw 'match t)))))
(defun moinmoin-setup-font-lock ()
(setq font-lock-beginning-of-syntax-function '(lambda () (goto-char 1)))
(setq font-lock-multiline t)
(make-local-variable 'font-lock-extra-managed-props)
(add-to-list 'font-lock-extra-managed-props 'moinmoin-verbatim) ; Not Comment Start
(add-to-list 'font-lock-extra-managed-props 'display)
(font-lock-add-keywords nil `(
("\\(?:^\\|[^|]\\)\\(\\(?:||\\)+\\)\\(<.*?>\\)?"
(1 'moinmoin-table-separator)
(2 'moinmoin-table-pi t t))
("'''\\(.*?\\)'''" (1 'moinmoin-bold prepend))
("\\(?:[^']\\|^\\)''\\([^'].*?[^']\\)''[^']" (1 'moinmoin-italic prepend))
("\\(__\\)\\(.*?\\)\\(__\\)"
(1 'moinmoin-ss t) (2 'moinmoin-underline prepend) (3 'moinmoin-ss t))
("\\(--(\\)\\(.*?\\)\\()--\\)"
(1 'moinmoin-ss t) (2 'moinmoin-stroke prepend) (3 'moinmoin-ss t))
("\\(,,\\)\\(.*?\\)\\(,,\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-subscript 'display '(raise -0.3)) prepend)
(3 'moinmoin-ss t))
("\\(\\^\\)\\(.*?\\)\\(\\^\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-superscript 'display '(raise 0.3)) prepend)
(3 'moinmoin-ss t))
("''+" (0 'moinmoin-ss t))
("^ +\\(?:\\*\\|.*?::\\|\\(?:[0-9]+\\|[aAiI]\\)\\.\\) "
(0 'moinmoin-item-2))
("^ \\(?:\\*\\|.*?::\\|\\(?:[0-9]+\\|[aAiI]\\)\\.\\) "
(0 'moinmoin-item))
("^\\( +\\)\\(.*\\)"
(1 'moinmoin-blockquote-indent)
(2 'moinmoin-blockquote-text))
("&[A-Za-z0-9]*;" (0 'moinmoin-entity prepend))
(,(concat "\\(?:^\\| \\)\\(" moinmoin-smiley-re "\\)[[:space:]]")
(1 'moinmoin-smiley t))
("\\(?:^\\|[^A-Za-z!]\\)\\(\\(?:\\.\\./\\)?/?[A-Z][a-z]+[A-Z][a-z][A-Za-z]*\\(?:/[A-Z][a-z]+[A-Z][a-z][A-Za-z]*\\)?\\)"
(1 'moinmoin-wiki-link t))
(,(concat "[A-Z][A-Za-z]+:"
"[^[:space:]'\":<|]"
"\\(?:[^" moinmoin-url-punctuation "[:space:]]\\|"
"[" moinmoin-url-punctuation "]"
"[^" moinmoin-url-punctuation "[:space:]]\\)+")
(0 'moinmoin-inter-wiki-link t))
("\\(\\[\"\\)\\(?:\\(.*?:.*\\)\\|\\(.*?\\)\\)\\(\"\\]\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-inter-wiki-link 'moinmoin-verbatim t) t t)
(3 (list 'face 'moinmoin-wiki-link 'moinmoin-verbatim t) t t)
(4 'moinmoin-ss t))
;;ur'%(url_guard)s(%(url)s)\:([^\s\<%(punct)s]|([%(punct)s][^\s\<%(punct)s]))+'
(,(concat "\\<" moinmoin-url-prefix ":"
"\\(?:[^" moinmoin-url-punctuation "<[:space:]]\\|"
"[" moinmoin-url-punctuation "]"
"[^" moinmoin-url-punctuation "<[:space:]]\\)+")
(0 'moinmoin-url t))
("[A-Za-z0-9_+-]+@[A-Za-z0-9_-]+\\(?:\\.[A-Za-z0-9_-]+\\)+"
(0 'moinmoin-email t))
("-\\{4,\\}" (0 'moinmoin-rule t))
;; macros
("\\(\\[\\[\\)\\([A-Za-z0-9]+\\)\\(?:\\((\\)\\(.*?\\)\\()\\)\\)?\\(\\]\\]\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-macro-name 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t t)
(4 (list 'face 'moinmoin-macro-parameters 'moinmoin-verbatim t) t t)
(5 'moinmoin-ss t t)
(6 'moinmoin-ss t))
("\\(\\[\\[Anchor(\\)\\(.*?\\)\\()\\]\\]\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-anchor 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t))
("\\(\\[#\\)\\(.*?\\) +\\(.*?\\)?\\(\\]\\)"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-anchor-ref-id 'moinmoin-verbatim t) t)
(3 (list 'face 'moinmoin-anchor-ref-title 'moinmoin-verbatim t) t t)
(4 (list 'face 'moinmoin-ss 'moinmoin-verbatim t) t))
;; typewriter (tt) overrides the above
("\\({{{\\)\\(.*?\\)\\(}}}\\)"
(1 (list 'face 'moinmoin-ss 'moinmoin-verbatim t) keep)
(2 (list 'face 'moinmoin-tt 'moinmoin-verbatim t) t)
(3 (list 'face 'moinmoin-ss 'moinmoin-verbatim t) keep))
("\\(`\\)\\(.*?\\)\\(`\\)"
(1 'moinmoin-ss keep) ; cannot match `{{{' thus no need for ncs
(2 (list 'face 'moinmoin-tt 'moinmoin-verbatim t) t)
(3 'moinmoin-ss keep))
;; headers overrides tt and biu
("^\\(= \\)\\(.*\\)\\( =\\)$"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-h1 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t))
("^\\(== \\)\\(.*\\)\\( ==\\)$"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-h2 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t))
("^\\(=== \\)\\(.*\\)\\( ===\\)$"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-h3 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t))
("^\\(==== \\)\\(.*\\)\\( ====\\)$"
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-h4 'moinmoin-verbatim t) t)
(3 'moinmoin-ss t))
("^\\(=====\\(=*\\) \\)\\(.*\\)\\( \\2=====\\)$" ; 5th and all others
(1 'moinmoin-ss t)
(3 (list 'face 'moinmoin-h5 'moinmoin-verbatim t) t)
(4 'moinmoin-ss t))
;; comments and pi
("^##.*$"
(0 (list 'face 'moinmoin-comment 'moinmoin-verbatim t) t))
(,moinmoin-pi-re
(0 (list 'face 'moinmoin-pi 'moinmoin-verbatim t) t))
(moinmoin-bracketed-url-matcher
(1 'moinmoin-ss t)
(2 (list 'face 'moinmoin-url 'moinmoin-verbatim t) t)
(3 (list 'face 'moinmoin-url-title 'moinmoin-verbatim t) t t)
(4 (list 'face 'moinmoin-ss 'moinmoin-verbatim t) t))
(moinmoin-formatted-code-matcher
(1 (list 'face 'moinmoin-code-braces 'moinmoin-verbatim t) t)
(2 (list 'face 'moinmoin-pi 'moinmoin-verbatim t) t t)
(3 (list 'face 'moinmoin-code 'moinmoin-verbatim t) t)
(4 (list 'face 'moinmoin-code-braces 'moinmoin-verbatim t) t))
) 'set))
;;; Automagic typing helpers
(defun moinmoin-insert-quote ()
"Convert double quote to HTML entity (&ldquo; or &rdquo;)"
(interactive)
(cond
((or (get-text-property (point) 'moinmoin-verbatim)
(looking-back "\\[\\|= *\\|^\\(?:[^\"]*\"[^\"]*\"\\)*[^\"]*\"[^\"]*"))
(insert "\""))
((or (looking-back "[[:space:]]") (eq (point) 1))
(insert "&ldquo;"))
(t (insert "&rdquo;"))))
(defun moinmoin-insert-dash ()
"Insert different types of dashes.
`----' and `-' stays unchanged
`--' is converted to `&ndash;'
`---' is converted to `&mdash;'
`)--' is not changed'
`<-' is converted to `&larr;'"
(interactive)
(cond
((get-text-property (point) 'moinmoin-verbatim)
(insert "-"))
((looking-back "---\\|&mdash;")
(replace-match "----" t t))
((looking-back "--\\|&ndash;")
(replace-match "&mdash;" t t))
((looking-back ")-")
(replace-match ")--" t t))
((looking-back "<")
(replace-match "&larr;" t t))
((looking-back "-")
(replace-match "&ndash;" t t))
(t (insert "-"))))
(defun moinmoin-insert-lparen ()
"&ndash;( to --("
(interactive)
(cond
((get-text-property (point) 'moinmoin-verbatim)
(insert "("))
((looking-back "&ndash;")
(replace-match "--(" t t))
(t (insert "("))))
(defun moinmoin-insert-greater-than ()
"-> to &rarr;"
(interactive)
(cond
((get-text-property (point) 'moinmoin-verbatim)
(insert ">"))
((looking-back "-")
(replace-match "&rarr;" t t))
(t (insert ">"))))
(defun moinmoin-insert-item ()
"Start new item or row
If current line starts with item prefix insert newline and the same
prefix in front of the rest of line.
If it is table then finish the line and add the new one"
(interactive)
(when (bolp) (backward-char))
(cond
((looking-back "^\\( *||\\).*") ; in a table
(let ((prefix (match-string 1)))
(end-of-line)
(looking-back "[^|]\\(|*\\)")
(replace-match "||" t t nil 1)
(insert "\n" prefix)))
((looking-back "^\\( +\\(?:\\* \\|\\(?:[0-9]+\\|[aAiI]\\)\\. \\|\\)\\).*")
(let ((prefix (match-string 1)))
(insert "\n")
(insert prefix)))))
;;; Header manipulation helpers
(defun moinmoin-is-header ()
"Is point in a header line?
If yes the title is in \\1"
(save-excursion
(beginning-of-line)
(looking-at "=+ \\(.*\\) =+$")))
(defun moinmoin-increase-header-level ()
"Add `=' in the beginning and end of current line"
(save-excursion
(beginning-of-line) (insert "=")
(end-of-line) (insert "=")))
(defun moinmoin-decrease-header-level ()
"Decrease level of the header
Warns if point in a top-level header or not in a header"
(save-excursion
(beginning-of-line)
(if (looking-at "=\\(=+ .* =+\\)=$")
(replace-match "\\1" t)
(warn "cannot decrease level"))
))
(defun moinmoin-change-header-level (increment)
"Increase or decrease level of header according to INCREMENT"
(interactive "r")
(if (eq increment 1)
(moinmoin-increase-header-level)
(moinmoin-decrease-header-level)))
(defun moinmoin-change-header-levels-in-region (increment start end)
"Increase or decrease level of all headers in the region according to INCREMENT"
(interactive "p\nr")
(save-excursion
(goto-char start)
(while (progn
(when (moinmoin-is-header)
(moinmoin-change-header-level increment))
(and (zerop (forward-line)) (< (point) end))))
))
(defun moinmoin-insert-equal (increment)
"Do-what-I-mean with header level or insert `='.
With active region increase or decrease level of all headers in region.
On an empty line starts new header.
On a header line increase or decrease level.
Otherwise just insert `='"
(interactive "p")
(if mark-active
(progn
(moinmoin-change-header-levels-in-region
increment (region-beginning) (region-end))
(setq deactivate-mark nil))
(cond
((looking-at "^$")
(insert "= =")
(backward-char 2))
((moinmoin-is-header)
(moinmoin-change-header-level increment))
(t (insert "=")))))
;;; Anchor insertion and navigation
(defun moinmoin-list-anchors ()
"List anchors in the current buffer"
(let ((lst))
(save-excursion
(goto-char 1)
(while (search-forward-regexp "\\[\\[Anchor(\\([^])\n]*\\))\\]\\]" nil t)
(setq lst (cons (match-string-no-properties 1) lst))))
lst))
(defvar moinmoin-anchor-history "Minibuffer history of anchors")
(defun moinmoin-completing-read-anchor (prompt &optional require-match)
"Read non-empty anchor using complition of all the anchors in the current buffer"
(let ((anchor
(completing-read "Anchor: " (moinmoin-list-anchors)
nil require-match
nil moinmoin-anchor-history)))
(when (string-equal anchor "")
(error "Empty anchor"))
anchor))
(defun moinmoin-insert-number-sign (&optional no-title)
(interactive "P")
"After `[' insert a reference to anchor inputed using completition,
If no argument given also insert the title of the section which contains
the anchor."
(cond
((and (looking-back "\\[")
(not (get-text-property (point) 'moinmoin-verbatim)))
(let* ((anchor (moinmoin-completing-read-anchor "Anchor: "))
(title
(unless no-title
(condition-case nil
(moinmoin-get-anchored-header anchor)
(error (message "No header for anchor %s" anchor) nil)))))
(insert "#" anchor " ")
(if title
(insert title "]")
(insert "]") (backward-char))))
(t ; not after "["
(insert "#"))))
(defun moinmoin-insert-anchor ()
"Insert anchor (using the title if point is in a header)"
(interactive)
(cond
((moinmoin-is-header)
(let ((anchor-name
(replace-regexp-in-string ; remove non-anchor symbols
"[^A-Za-z0-9]+" "-"
(match-string-no-properties 1) t t)))
(forward-line)
(insert "[[Anchor(" anchor-name ")]]\n")))
(t
(insert "[[Anchor()]]") (backward-char 3))))
(defun moinmoin-anchor-read-or-ask (&optional prompt)
"DWIM to get anchor: read [#... ] on current line (before point) or ask user."
(cond
((and
(search-backward
"[#" (save-excursion (beginning-of-line) (point)) t)
(looking-at "\\[#\\([^]\n ]+\\)"))
(match-string-no-properties 1))
(t
(moinmoin-completing-read-anchor (or prompt "Anchor: ") t))))
(defun moinmoin-goto-anchor (&optional anchor)
"Go to anchor
If ANCHOR is nil (e.g., if called interactively) read reference
to it from the current line or ask user. So if there is an
anchor on the current line but you want to jump to something
different go to the beginning of the line first."
(interactive)
(unless anchor
(setq anchor (moinmoin-anchor-read-or-ask)))
(goto-char 1)
(search-forward (concat "[[Anchor(" anchor ")]]")))
(defun moinmoin-get-anchored-header (anchor)
"Get title of the section which contains ANCHOR"
(save-excursion
(moinmoin-goto-anchor anchor)
(search-backward-regexp "^=+ \\(.*\\) =+$" nil)
(match-string-no-properties 1)))
(defun moinmoin-insert-anchored-header (&optional to-kill-ring)
"Insert title of the section which contains anchor, with prefix save it to kill-ring"
(interactive "P")
(let ((header (moinmoin-get-anchored-header nil)))
(if to-kill-ring
(kill-new header)
(insert header))))
;;; Setup
(define-derived-mode moinmoin-mode outline-mode "MoinMoin"
"Set major mode for editing MoinMoin pages"
(make-local-variable 'outline-regexp)
(setq outline-regexp "=+")
(make-local-variable 'outline-heading-end-regexp)
(setq outline-heading-end-regexp " =+\n")
(local-set-key "\"" 'moinmoin-insert-quote)
(local-set-key "-" 'moinmoin-insert-dash)
(local-set-key "(" 'moinmoin-insert-lparen)
(local-set-key ">" 'moinmoin-insert-greater-than)
(local-set-key "=" 'moinmoin-insert-equal)
(local-set-key "#" 'moinmoin-insert-number-sign)
(local-set-key (kbd "M-RET") 'moinmoin-insert-item)
(local-set-key (kbd "C-c a") 'moinmoin-insert-anchor)
(local-set-key (kbd "C-c g") 'moinmoin-goto-anchor)
(toggle-truncate-lines 0) ; do not truncate
(moinmoin-setup-font-lock)
(abbrev-mode 1)
(set-fill-column 65000)
(auto-fill-mode 0))
(add-to-list 'auto-mode-alist '("\\.wiki$" . moinmoin-mode))
(provide 'moinmoin-mode)

View File

@ -52,13 +52,13 @@
(sit-for 1)
(split-window-horizontally)
(other-window 1)
(org-journal-open-current-journal-file))))
(org-roam-dailies-goto-today))))
(defun mmk2410/tab-bar-run-journal ()
(interactive)
(mmk2410/tab-bar-switch-or-create
"Journal"
#'org-journal-open-current-journal-file))
#'org-roam-dailies-goto-today))
(defun mmk2410/tab-bar-run-projects ()
(interactive)
@ -91,5 +91,4 @@
("q" nil))
(provide 'mmk2410-tab-bar-helpers)
;;; tab-bar-helpers.el ends here
;;; mmk2410-tab-bar-helpers.el ends here

View File

@ -0,0 +1,40 @@
;;; org-quick-capture.el --- Open a org capture frame and close it directly afterwards. -*- lexical-binding: t; -*-
;;; Commentary:
;;; The code is grabbed from Reddit
;;; (https://www.reddit.com/r/emacs/comments/74gkeq/system_wide_org_capture/)
;;; and was written by u/lebitso (https://www.reddit.com/user/lebitso)
;;; with the help of an anoymous other user.
;;; Code:
(require 'org)
(require 'org-capture)
(defadvice org-switch-to-buffer-other-window
(after supress-window-splitting activate)
"Delete the extra window if we're in a capture frame."
(if (equal "Org Capture" (frame-parameter nil 'name))
(delete-other-windows)))
(defadvice org-capture-finalize
(after delete-capture-frame activate)
"Advise capture-finalize to close the frame when finished."
(when (and (equal "Org Capture" (frame-parameter nil 'name))
(not (eq this-command 'org-capture-refile)))
(delete-frame)))
(defadvice org-capture-refile
(after delete-capture-frame activate)
"Advise org-refile to close the frame when finished."
(delete-frame))
(defun org-quick-capture ()
"Run 'org-capture' in an own capture frame."
(select-frame-by-name "Org Capture")
(switch-to-buffer (get-buffer-create "*scratch*"))
(org-capture))
(provide 'org-quick-capture)
;;; org-quick-capture.el ends here

466
packages/ts-mode.el Normal file
View File

@ -0,0 +1,466 @@
;;; ts-mode.el --- An Emacs major mode for editing TypoScript files
;; Copyright (C) 2009 Joachim Mathes
;;
;; Author: Joachim Mathes <joachim <underscore> mathes <at> web <dot> de>
;; Created: July 2009
;; Version: 0.1
;; Last-Updated: Thu Aug 13 00:18:18 CEST 2009
;; By: Joachim Mathes
;; Update #: 4
;; Keywords: files
;; URL: http://www.emacswiki.org/emacs/ts-mode.el
;; EmacsWiki: TypoScriptMode
;; This file 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, or (at your option)
;; any later version.
;; This file 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; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Installation:
;; To install just drop this file into a directory on your load-path and
;; byte-compile it. To set up Emacs to automatically edit files ending in ".ts"
;; using ts-mode add the following to your ~/.emacs file (GNU Emacs) or
;; ~/.xemacs/init.el file (XEmacs):
;; (setq auto-mode-alist (cons '("\\.ts$" . ts-mode) auto-mode-alist))
;; (autoload 'ts-mode "ts-mode" "TypoScript file editing mode." t)
;; Description:
;; This is a major mode for editing TypoScript input files. It is developed to
;; support syntax highlighting, indentation and folding of blocks.
;; This file is *NOT* part of GNU Emacs.
;;; History:
;;
;;; Code:
(defconst ts-version "0.1"
"`ts-mode' version number.")
;; User definable variables
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(defgroup typoscript nil
"Major mode for editing TypoScript files."
:prefix "ts-"
:group 'languages)
(defcustom ts-newline-function 'newline-and-indent
"Function to be called upon pressing `RET'."
:type '(choice (const newline)
(const newline-and-indent)
(const reindent-then-newline-and-indent))
:group 'typoscript)
(defcustom ts-block-indentation 2
"The indentation relative to a predecessing line which begins a new block.
In TypoScript blocks start with the left parenthesis `(' or the left brace
`{'."
:type 'integer
:group 'typoscript)
(defcustom ts-fold-foreground-color "white"
"The foreground color used to highlight the folded block.
The default value is `white'. For a list of all available colors use `M-x
list-colors-display'"
:type 'color
:group 'typoscript)
(defcustom ts-fold-background-color "DodgerBlue1"
"The background color used to highlight the folded block.
The default value is `DodgerBlue1'. For a list of all available colors use
`M-x list-colors-display'"
:type 'color
:group 'typoscript)
;; Internal variables
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(defvar ts-mode-hook nil
"Hook called by `ts-mode'.")
(defvar ts-classes-face 'ts-classes-face
"Face for TypoScript classes.")
(make-face 'ts-classes-face)
(defvar ts-path-face 'ts-path-face
"Face for TypoScript paths.")
(make-face 'ts-path-face)
(defvar ts-block-face 'ts-block-face
"Face for TypoScript blocks.")
(make-face 'ts-block-face)
(defvar ts-conditional-face 'ts-conditional-face
"Face for TypoScript conditionals.")
(make-face 'ts-conditional-face)
(defvar ts-html-face 'ts-html-face
"Face for TypoScript HTML tags.")
(make-face 'ts-html-face)
(defun ts-font-lock-mode-hook ()
"Defines a TypoScript font lock mode hook."
(or (face-differs-from-default-p 'ts-classes-face)
(copy-face 'font-lock-keyword-face 'ts-classes-face))
(copy-face 'font-lock-builtin-face 'ts-path-face)
(set-face-foreground 'ts-path-face
"DarkTurquoise" nil)
(copy-face 'font-lock-builtin-face 'ts-block-face)
(set-face-foreground 'ts-block-face
"DodgerBlue1" nil)
(copy-face 'font-lock-builtin-face 'ts-conditional-face)
(set-face-foreground 'ts-conditional-face
"maroon" nil)
(copy-face 'font-lock-builtin-face 'ts-html-face)
(set-face-foreground 'ts-html-face
"ForestGreen" nil))
(defvar ts-font-lock-keywords
(let ((kw1 (mapconcat 'identity
;; Basic TypoScript classes
'("CONFIG" "PAGE" "TEXT" "COA" "COA_INT"
"FILE" "IMAGE" "GIFBUILDER" "CASE" "TEMPLATE"
"HMENU" "GMENU" "CONTENT")
"\\|")))
(list
;; Paths
'("^[ \t]*\\([[:alnum:]-_\\.]+\\)[ \t]*[=<>]" 1 'ts-path-face)
;; Blocks
'("^[ \t]*\\([[:alnum:]-_\\.]+\\)[ \t]*[{(]" 1 'ts-block-face)
;; Periods
;;'("^[ \t]*" "\\(\\.\\)" nil nil (1 'default t))
;; Classes (keywords)
(list (concat "\\<\\(" kw1 "\\)\\>") 1 'ts-classes-face t)
;; Conditional expressions `[...]'
'("^[ \t]*\\(\\[.+?\\]\\)[ \t]*$" 1 'ts-conditional-face)
;; Comment lines beginning with hash symbol `#'
'("^[ \t]*\\(#.*\\)$" 1 'font-lock-comment-face)
;; HTML special character encodings on the right side of the operator
'("\\(=\\|=<\\|>\\|:=\\)" "\\(&[#[:alnum:]]+;\\)" nil nil (0 'ts-html-face))
;; HTML tags
'("=<?\\|>\\|:=\\|[ \t]*" "\\(<[^<]+?>\\)" nil nil (0 'ts-html-face))
;; HTML color definitions
'("#[[:xdigit:]]\\{6\\}[ \t\n]+" 0 'ts-html-face t)))
"Expressions to highlight in TypoScript mode.")
(defvar ts-mode-syntax-table nil
"Syntax table used in TypoScript Mode buffers.")
(defvar ts-mode-map ()
"Key map used in TypoScript Mode buffers.")
(defvar ts-highlight-overlays [nil nil]
"A vector of different overlay to do highlighting.
This vector concerns only highlighting of horizontal lines.")
;; Functions
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
;;;###autoload
(defun ts-mode ()
"Major mode for editing TypoScript files.
Bug reports, suggestions for new features and critics should go to
`joachim_mathes@web.de'.
This mode knows about syntax highlighting, indentation and folding of
blocks.
COMMANDS
\\{ts-mode-map}
VARIABLES
ts-newline-function\t\tbehaviour after pressing `RET'
ts-block-indentation\t\tindentation value
ts-fold-foreground-color\t\tforeground color of folded measurement block
ts-fold-background-color\t\tbackground color of folded measurement block"
(interactive)
;; Set up local variables
(kill-all-local-variables)
(make-local-variable 'font-lock-defaults)
(make-local-variable 'comment-start)
(make-local-variable 'comment-end)
(make-local-variable 'comment-start-skip)
(make-local-variable 'indent-line-function)
(make-local-variable 'defun-prompt-regexp)
(when (not ts-mode-syntax-table)
(setq ts-mode-syntax-table (make-syntax-table))
;; Parenthesis, brackets and braces
(modify-syntax-entry ?\( "()" ts-mode-syntax-table)
(modify-syntax-entry ?\) ")(" ts-mode-syntax-table)
(modify-syntax-entry ?\[ "(]" ts-mode-syntax-table)
(modify-syntax-entry ?\] ")[" ts-mode-syntax-table)
(modify-syntax-entry ?\{ "(}" ts-mode-syntax-table)
(modify-syntax-entry ?\} "){" ts-mode-syntax-table)
;; Comment delimiters
(modify-syntax-entry ?/ ". 124b" ts-mode-syntax-table)
(modify-syntax-entry ?* ". 23" ts-mode-syntax-table)
(modify-syntax-entry ?\n "> b" ts-mode-syntax-table)
(modify-syntax-entry ?\" "." ts-mode-syntax-table)
(modify-syntax-entry ?. "." ts-mode-syntax-table))
(set-syntax-table ts-mode-syntax-table)
(add-hook 'font-lock-mode-hook 'ts-font-lock-mode-hook)
(setq defun-prompt-regexp "^[ \t]*\\([[:alnum:]-_\\.]+\\)[ \t]*")
(if ts-mode-map
nil
(setq ts-mode-map (make-sparse-keymap))
(define-key ts-mode-map "\r" 'ts-newline)
(define-key ts-mode-map "\C-c\C-e" 'ts-fold-block)
(define-key ts-mode-map "\C-c\C-a" 'ts-unfold-block)
(define-key ts-mode-map "\C-c\C-u\C-r" 'ts-unfold-region)
(define-key ts-mode-map "\C-c\C-u\C-b" 'ts-unfold-buffer)
(define-key ts-mode-map "}" 'ts-electric-brace)
(define-key ts-mode-map ")" 'ts-electric-brace))
(use-local-map ts-mode-map)
(setq major-mode 'ts-mode
mode-name "TypoScript"
font-lock-defaults '(ts-font-lock-keywords)
comment-start "# "
comment-end ""
comment-start-skip "# "
indent-line-function 'ts-indent-line)
;; Run the mode hook.
(if ts-mode-hook
(run-hooks 'ts-mode-hook)))
(defun ts-newline ()
"Call the dedicated newline function.
The variable `ts-newline-function' decides which newline function to
use."
(interactive)
(funcall ts-newline-function))
(defun ts-indent-line ()
"Indent current line for TypoScript mode."
(let ((cp (point)) ; current point
(cc (current-column)) ; current column
(ci (current-indentation)) ; current indentation
(cl (line-number-at-pos)) ; current line
(counter 0)
ps ; parser state
psp ; parser state position
save-indent-column)
;; Evaluate parser state
(save-excursion
(beginning-of-line)
(setq ps (ts-parser-state))
(cond
;; Check if parser state position is:
;; -> Inside a comment
((nth 8 ps)
(setq psp (nth 8 ps))
(goto-char psp)
(setq save-indent-column (+ (current-column)
1)))
;; Check if parser state position is:
;; -> Inside a parenthetical grouping
((nth 1 ps)
(setq psp (nth 1 ps))
(cond
;; Check if point is looking at a string and a closing curly brace
((looking-at "[ \t[:alnum:]]*[)}]")
(goto-char psp)
(back-to-indentation)
(setq save-indent-column (current-column)))
(t
(goto-char psp)
(back-to-indentation)
(setq save-indent-column (+ (current-column)
ts-block-indentation)))))
;; Check if parser state position is:
;; -> nil
(t
;; Skip empty lines
(forward-line -1)
(while (and (looking-at "^[ \t]*\n")
(not (bobp)))
(forward-line -1))
(back-to-indentation)
(setq save-indent-column (current-column)))))
;; Set indentation value on current line
(back-to-indentation)
(backward-delete-char-untabify (current-column))
(indent-to save-indent-column)
(if (> cc ci)
(forward-char (- cc ci)))))
(defun ts-parser-state ()
"Return the parser state at point."
(save-excursion
(let ((here (point))
sps)
;; For correct indentation the character position of the start of the
;; innermost parenthetical grouping has to be found.
(goto-char (point-min))
;; Now get the parser state, i.e. the depth in parentheses.
(save-excursion
(setq sps (parse-partial-sexp (point) here)))
sps)))
(defun ts-block-start ()
"Return buffer position of the last unclosed enclosing block.
If nesting level is zero, return nil."
(let ((status (ts-parser-state)))
(if (<= (car status) 0)
nil
(car (cdr status)))))
;; Electric characters
(defun ts-electric-brace (arg)
"Insert closing brace.
Argument ARG prefix."
(interactive "*P")
;; Insert closing brace.
(self-insert-command (prefix-numeric-value arg))
(when (and (looking-at "[ \t]*$")
(looking-back "^[ \t]*[})]"))
(ts-indent-line)))
;; Folding
(defun ts-fold-block ()
"Hide the block on which point currently is located."
(interactive)
(let ((current-point (point))
(block-start (ts-block-start)))
(if (not block-start)
(message "Point is not within a block.")
;; Look for block start
(save-excursion
(goto-char (ts-block-start))
(beginning-of-line)
(setq block-start (point)))
(when block-start
(let ((block-name
;; Save block name
(save-excursion
(goto-char block-start)
(beginning-of-line)
(looking-at
"^[ \t]*\\(.*?\\)[ \t]*{")
(match-string 1)))
(block-end
;; Look for block end
(save-excursion
(goto-char block-start)
(forward-list)
(point)))
;; Variable for overlay
skampi-overlay)
;; ------------------------------------------------------------------
;; The following local variables are defined up to here:
;; [1] block-start: point of block start, at the beginning
;; of the line; nil otherwise
;; [2] block-name : name of block, i.e. the object path
;; [3] block-end : point of block end, at the end of the
;; line which contains the closing curly brace `}
;; ------------------------------------------------------------------
;; Check if end of measurement block is beyond point;
;; call fold function otherwise
(if (>= block-end current-point)
(ts-fold block-start block-end block-name)
(message "Error: No valid block found."))
;; Indent overlay
(goto-char block-start)
(beginning-of-line)
(ts-indent-line))))))
(defun ts-fold (block-start block-end block-name)
"Fold block.
The block starts at BLOCK-START and ends at BLOCK-END. Its
BLOCK-NAME is the TypoScript object path."
(let (ts-overlay)
;; Check if block-start and block-end are valid values, i.e. not nil
(if (or (eq block-start nil)
(eq block-end nil))
(message "Error: No valid block found.")
;; Make an overlay and hide block
(setq ts-overlay (make-overlay block-start block-end
(current-buffer) t nil))
(overlay-put ts-overlay 'category 'ts-fold)
(overlay-put ts-overlay 'evaporate t)
(overlay-put ts-overlay 'mouse-face 'highlight)
(overlay-put ts-overlay 'display (concat "["
(propertize block-name
'face
nil)
"]"))
(overlay-put ts-overlay 'font-lock-face `(:foreground ,ts-fold-foreground-color
:background ,ts-fold-background-color))
(overlay-put ts-overlay 'help-echo (concat
"Folded block: "
block-name)))))
(defun ts-unfold-buffer ()
"Unfold all blocks in the buffer."
(interactive)
(ts-unfold-region (point-min) (point-max)))
(defun ts-unfold-region (start end)
"Unfold all blocks in the region.
The region delimiters are START and END."
(interactive "r")
(let ((ts-overlays (overlays-in start end)))
(ts-unfold-overlays ts-overlays)))
(defun ts-unfold-block ()
"Unfold block at point."
(interactive)
(let ((ts-overlays (overlays-at (point))))
(ts-unfold-overlays ts-overlays)))
(defun ts-unfold-overlays (ts-overlays)
"Unfold all overlays set by ts-fold in TS-OVERLAYS.
Return non-nil if an unfold happened, nil otherwise."
(let (found)
(dolist (overlay ts-overlays)
(when (eq (overlay-get overlay 'category) 'ts-fold)
(delete-overlay overlay)
(setq found t)))
found))
(provide 'ts-mode)
;;; ts-mode.el ends here