├── .gitignore
├── .gitmodules
├── Makefile
├── README.md
├── abbrevs.el
├── doc
└── EmacsWiki
│ ├── BbdbExporters
│ ├── CategoryRegexp
│ ├── ConcurrentEmacs
│ ├── EncryptingMail
│ ├── ErcYank
│ ├── Framework_extending_window_functions_for_Follow_Mode_(etc.)
│ ├── MozRepl
│ ├── ParEdit
│ ├── Proposals
│ ├── RectangleAdd
│ ├── RememberMode
│ ├── SelectKey
│ └── UsePackage
├── empowered-by-gnu.svg
├── gerwinski-gnu-head.png
├── init.org
├── lisp
├── README.org
├── aibo-hack.el
├── c-includes.el
├── cl-info.el
├── copy-code.el
├── coq-lookup.el
├── delimit.el
├── drafts.el
├── dsel-example.el
├── ediff-keep.el
├── edit-rectangle.el
├── emacs-edg
│ ├── README.md
│ └── edg.el
├── erc-alert.el
├── erc-macros.el
├── erc-patch.el
├── erc-question.el
├── esh-toggle.el
├── eshell-ext-29.4.el
├── eshell-ext-30.1.el
├── eshell-ext-HEAD.el
├── fetchmail-ctl.el
├── fo76-custom.el
├── gnus-harvest
│ └── gnus-harvest.el
├── gptel-ext.el
├── gptel-proof.el
├── gptel-rag.el
├── gptel-temp.el
├── gptel-tools.el
├── graph.el
├── haskell-yas.el
├── heap.el
├── howard.el
├── html.el
├── inventory.el
├── karthik-folds.el
├── llm.el
├── loeb.el
├── lzw.el
├── main.el
├── merlin.el
├── my-gnus-score.el
├── onnx-example.el
├── org-agenda-overlay.el
├── org-agenda-random.el
├── org-balance.el
├── org-color.el
├── org-config.el
├── org-constants.el
├── org-debbugs.el
├── org-devonthink.el
├── org-ext.el
├── org-ql-ext.el
├── org-roam-ext.el
├── org-roam-logseq.el
├── org-smart-capture.el
├── paredit-ext.el
├── persian-johnw.el
├── personal.el
├── prover.el
├── regex-tool
│ ├── TODO
│ └── regex-tool.el
├── ruhi.el
├── sh-toggle.el
├── springboard
│ ├── README.md
│ ├── ido-springboard.el
│ └── springboard.el
├── stock-quote.el
├── vulpea-ext.el
├── vulpea-field.el
└── z3.el
├── org-auto-expand-bug.org
├── prompts
├── board.md
├── default.txt
├── haskell.txt
├── persian.txt
├── prompt.txt
├── proof.txt
├── proofread.txt
├── review.md
├── shorten.txt
├── spanish.poet
└── title.txt
├── runshell
└── snippets
├── agda2-mode
├── begin
├── eq
└── eqr
├── c++-mode
└── .yas-parents
├── c-mode
└── .yas-parents
├── cc-mode
├── class
├── com
├── fopen
├── inc
├── inc.1
├── main
├── ns
├── once
└── using
├── coq-mode
├── all
├── comp
├── deb
├── exist
├── header
├── imp
├── ind!
├── inst
├── l
├── lemma
├── not
├── r
└── sind
├── emacs-lisp-mode
├── hdr
└── test
├── erc-mode
├── ftp
├── gchat
└── tiny
├── fundamental-mode
├── date
├── mail
└── time
├── gptel-mode
└── xlat
├── latex-mode
├── acro
├── code
├── gloss
└── hafez
├── lisp-mode
├── case
├── ccase
├── cond
├── ctypecase
├── defclass
├── defconstant
├── defgeneric
├── define-compiler-macro
├── define-condition
├── define-symbol-macro
├── defmacro
├── defmethod
├── defpackage
├── defparameter
├── defstruct
├── defsystem
├── deftype
├── defun
├── defvar
├── destructuring-bind
├── do
├── do_
├── dolist
├── dotimes
├── ecase
├── etypecase
├── flet
├── format
├── gnugpl
├── if
├── in-package
├── labels
├── let
├── mapc
├── mapcar
├── mitlic
└── typecase
├── message-mode
└── granted
├── org-mode
├── rust-mode
├── ma
└── parser
├── texinfo-mode
├── data
├── enum
├── ex
├── item
└── smex
└── text-mode
└── ggit
/.gitignore:
--------------------------------------------------------------------------------
1 | *.elc
2 | /data*/
3 | /emojis/
4 | /eshell/
5 | /init.el
6 | /persist/
7 | /projects
8 | /request/
9 | /settings.el
10 | /transient/
11 | /var/
12 | /elpy/
13 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lisp/use-package"]
2 | path = lisp/use-package
3 | url = git@github.com:jwiegley/use-package.git
4 | [submodule "lisp/alert"]
5 | path = lisp/alert
6 | url = git@github.com:jwiegley/alert.git
7 | [submodule "lisp/initsplit"]
8 | path = lisp/initsplit
9 | url = git@github.com:jwiegley/initsplit.git
10 | [submodule "lisp/emacs-pl"]
11 | path = lisp/emacs-pl
12 | url = git@github.com:jwiegley/emacs-pl.git
13 | [submodule "lisp/haskell-config"]
14 | path = lisp/haskell-config
15 | url = git@github.com:jwiegley/haskell-config.git
16 | [submodule "lisp/emacs-async"]
17 | path = lisp/async
18 | url = git@github.com:jwiegley/emacs-async.git
19 | [submodule "lisp/git-annex"]
20 | path = lisp/git-annex
21 | url = git@github.com:jwiegley/git-annex-el.git
22 | [submodule "lisp/erc-yank"]
23 | path = lisp/erc-yank
24 | url = git@github.com:jwiegley/erc-yank.git
25 | [submodule "lisp/chess"]
26 | path = lisp/chess
27 | url = git@github.com:jwiegley/emacs-chess.git
28 | [submodule "lisp/git-undo"]
29 | path = lisp/git-undo
30 | url = git@github.com:jwiegley/git-undo-el.git
31 | [submodule "lisp/nix-update"]
32 | path = lisp/nix-update
33 | url = git@github.com:jwiegley/nix-update-el.git
34 | [submodule "lisp/org-context"]
35 | path = lisp/org-context
36 | url = git@github.com:jwiegley/org-context.git
37 | [submodule "lisp/org-hash"]
38 | path = lisp/org-hash
39 | url = git@github.com:jwiegley/org-hash.git
40 | [submodule "lisp/gptel"]
41 | path = lisp/gptel
42 | url = git@github.com:karthink/gptel
43 | [submodule "lisp/llm-tool-collection"]
44 | path = lisp/llm-tool-collection
45 | url = git@github.com:skissue/llm-tool-collection
46 | [submodule "lisp/emacs-asana"]
47 | path = lisp/emacs-asana
48 | url = git@github.com:lmartel/emacs-asana
49 | [submodule "lisp/org-mode"]
50 | path = lisp/org-mode
51 | url = git://git.savannah.gnu.org/emacs/org-mode.git
52 | [submodule "lisp/emacs-format-all-the-code"]
53 | path = lisp/emacs-format-all-the-code
54 | url = git@github.com:lassik/emacs-format-all-the-code
55 | [submodule "lisp/mcp.el"]
56 | path = lisp/mcp.el
57 | url = git@github.com:lizqwerscott/mcp.el
58 | [submodule "lisp/vulpea"]
59 | path = lisp/vulpea
60 | url = git@github.com:jwiegley/vulpea.git
61 | [submodule "lisp/gptel-prompts"]
62 | path = lisp/gptel-prompts
63 | url = git@github.com:jwiegley/gptel-prompts.git
64 | [submodule "lisp/elisp-mcp-dev"]
65 | path = lisp/elisp-mcp-dev
66 | url = git@github.com:laurynas-biveinis/elisp-mcp-dev.git
67 | [submodule "lisp/gptel-eshell"]
68 | path = lisp/gptel-eshell
69 | url = git@github.com:karthink/gptel-eshell
70 | [submodule "lisp/DSel"]
71 | path = lisp/DSel
72 | url = git@github.com:cosmicz/DSel
73 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ## -*- mode: makefile-gmake -*-
2 |
3 | EMACS = emacs
4 | EMACS_BATCH = $(EMACS) -batch
5 |
6 | TARGET = $(patsubst %.el,%.elc,init.el)
7 |
8 | DIRS = lisp
9 | SUBDIRS = $(shell find $(DIRS) -maxdepth 2 \
10 | ! -name .git \
11 | ! -name doc \
12 | ! -name test \
13 | ! -name tests \
14 | ! -name obsolete \
15 | -type d -print)
16 |
17 | MY_LOADPATH = -L . $(patsubst %,-L %, $(SUBDIRS))
18 | BATCH_LOAD = $(EMACS_BATCH) $(MY_LOADPATH)
19 |
20 | .PHONY: test build clean
21 |
22 | # Main rule
23 | all: init.el
24 |
25 | init.org: ~/org/init.org
26 | @if test ~/org/init.org -nt $@; then \
27 | rm -f $@; \
28 | cp -p ~/org/init.org $@; \
29 | chmod 444 $@; \
30 | fi
31 |
32 | # Generate lisp and compile it
33 | init.el: init.org
34 | @rm -f $@
35 | @$(BATCH_LOAD) \
36 | --eval "(require 'org)" \
37 | --eval "(org-babel-load-file \"init.org\")"
38 | @chmod 444 $@
39 |
40 | %.elc: %.el
41 | @echo Compiling file $<
42 | @$(BATCH_LOAD) -f batch-byte-compile $<
43 |
44 | speed: init.elc
45 | time $(BATCH_LOAD) -Q -L . -l init \
46 | --eval "(message \"Hello, world\!\")"
47 |
48 | slow: init.el
49 | time $(BATCH_LOAD) -Q -L . -l init --debug-init \
50 | --eval "(message \"Hello, world\!\")"
51 |
52 | open: init.el
53 | @open $$(dirname $$(which emacs))/../Applications/*.app
54 |
55 | open-quick: init.el
56 | @open $$(dirname $$(which emacs))/../Applications/*.app
57 |
58 | clean:
59 | rm -f init.el *.elc *~ settings.el
60 |
61 | ### Makefile ends here
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # dot-emacs
2 |
3 | My .emacs file and other personal Emacs goodies.
4 |
5 | I keep my Emacs file in literate Org mode, so that it's easier to organize and
6 | also document how things are to be used, since there are enough packages that
7 | I often forget. You can view that document here:
8 |
9 | https://github.com/jwiegley/dot-emacs/blob/master/init.org
10 |
11 | NOTE: I no longer use git-subtree and submodules to track dependencies.
12 | Instead, everything is built and managed using Nix and Nix overlays:
13 | https://github.com/jwiegley/nix-config/blob/master/overlays/10-emacs.nix
14 |
--------------------------------------------------------------------------------
/abbrevs.el:
--------------------------------------------------------------------------------
1 | ;; -*- coding: utf-8 -*-
2 |
3 | (define-abbrev-table 'coq-mode-abbrev-table
4 | '(("refl" "Proof. reflexivity. Qed.")))
5 |
6 | (define-abbrev-table 'message-mode-abbrev-table
7 | '(("linux" "GNU/Linux")))
8 |
9 | (define-abbrev-table 'global-abbrev-table
10 | '(("Abdul" "‘Abdu’l-Bahá")
11 | ("Allahu" "Alláh’u’Abhá")
12 | ("Aqdas" "Kitáb-i-Aqdas")
13 | ("Bahai" "Bahá’í")
14 | ("Bahau" "Bahá’u’lláh")
15 | ("Iqan" "Kitáb-i-Íqán")
16 | ("LSA" "Local Spiritual Assembly")
17 | ("NSA" "National Spiritual Assembly")
18 | ("UHJ" "Universal House of Justice")))
19 |
20 | ;; Local Variables:
21 | ;; after-save-hook: (check-parens quietly-read-abbrev-file)
22 | ;; End:
23 |
24 | ;;; abbrevs.el ends here
25 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/CategoryRegexp:
--------------------------------------------------------------------------------
1 | This category is about regular expressions. See also CategorySearchAndReplace.
2 |
3 |
4 | == Understanding Regular Expressions ==
5 |
6 | * RegularExpression -- what are regular expressions, anyway?
7 | * RegularExpressionHelp -- typical errors and frequently asked questions
8 | * RegexpReferences -- where to look for more information
9 | * CaseFoldSearch -- controlling case sensitivity when searching
10 | * MultilineRegexp -- how to match multiline content
11 | * NonAsciiRegexps -- dealing with non-ASCII characters
12 | * NonGreedyRegexp -- how to write .*?
in old emacsen
13 |
14 | == Using Regular Expressions Interactively ==
15 |
16 | * '''[[IncrementalSearch#RegexpSearches]]''' -- Using regexps with Isearch -- a good way to ''learn to use'' regexps
17 | * [[Icicles]] -- Another good way to ''learn to use'' regexps -- lots of different uses, including:
18 | ** [[Completion]] and cycling of completion candidates through regexp matching
19 | ** a new kind of incremental search: use multiple simple regexps, instead of struggling with a complex regexp; and regexp subgroups are highlighted individually
20 | * GrepMode -- `M-x grep' searches files for matches
21 | * OccurBuffer -- `M-x occur' works on buffers like `M-x grep' does on files
22 | * SearchBuffers -- Search *all* buffers
23 | * SearchAndReplaceDelimitedStrings -- Replace the prefix and suffix of a pattern while leaving the middle alone
24 | * GrepList -- search a list of strings for a regexp, recursing into sublists
25 | * OverlappingRegexps -- overlap regular expressions in a replace command
26 | * RecursiveGrep -- various commands that recursively search a file system
27 |
28 |
29 |
30 | == Programming with Regular Expressions ==
31 |
32 | * ReBuilder -- build a regexp string and watch what it matches as you type
33 | * Regex-tool -- similar to ReBuilder, found at http://github.com/jwiegley/regex-tool. See article [[http://www.newartisans.com/2007/10/a-regular-expression-ide-for-emacs.html|A regular expression IDE for Emacs]] by JohnWiegley
34 | * SymbolicRegexp -- for programmers who want to write readable regular expressions
35 | * [[rx]] -- macro that generates regexps from SymbolicRegexp
36 |
37 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/EncryptingMail:
--------------------------------------------------------------------------------
1 | Various packages:
2 |
3 | * EasyPG (used by Gnus)
4 | * S/MIME (GnusSMIME, ExtendSMIME)
5 | * DefaultEncrypt
6 | * Mailcrypt (BbdbAndMailCrypt)
7 | * bbdb-pgp.el (part of BbdbMode, see also http://my.gnus.org/Members/robin/Doc/howto_pgp) '''This link is broken'''
8 | * mc-bbdb.el
9 | * PGG (GnusPGG)
10 | * WlSigningMails for signing mails in WanderLust.
11 | * EncryptingAttachments for encrypting attached file using detached signatures.
12 |
13 | ----
14 | CategoryGnus CategoryMail CategoryMailAddons
15 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/ErcYank:
--------------------------------------------------------------------------------
1 | When people flooded EmacsChannel with code or debug messages instead of using
2 | [[lisppaste]], pjb mentioned his function `erc-yank', which is part of
3 | [http://darcs.informatimago.com/local/darcs/public/emacs/pjb-erc.el pjb-erc.el].
4 |
5 | `erc-yank' automatically adds pastes to http://paste.lisp.org/ if the text
6 | you want to yank is more than a certain number of lines long.
7 |
8 | Note that you'll need to use some of his personal libraries, available
9 | at http://darcs.informatimago.com/darcs/public/emacs/. [[w3]] is required as
10 | well.
11 |
12 | This file seems to have been developed using a somewhat older version of
13 | ERC than the latest release (it requires `erc-nets' which was renamed
14 | `erc-networks'). Changing the ##(require 'erc-nets)## to
15 | ##(require 'erc-networks)## and ##(require 'erc-nickserv)## to
16 | ##(require 'erc-services)## should fix that.
17 |
18 | ----
19 |
20 | I wrote a different, much simpler (16 line function) version of this that uses
21 | [https://github.com/defunkt/gist.el gist.el], available at
22 | https://github.com/jwiegley/erc-yank. -- JohnWiegley
23 |
24 | ----
25 | [[ERC]]
26 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/Framework_extending_window_functions_for_Follow_Mode_(etc.):
--------------------------------------------------------------------------------
1 | The goal of this proposal is to make it possible and easy for Emacs Lisp code
2 | to be compatible with Follow Mode. For this, a new framework will be
3 | developed.
4 |
5 | [h3]Requirements[/h3]
6 |
7 | * The framework will be non-intrusive: it will neither affect working code, nor force it to be amended.
8 | * The framework will not be tightly coupled with Follow Mode: Any future replacement for Follow Mode will slot into the framework readily.
9 | * Code will work in a uniform manner regardless of whether or not Follow Mode is active.
10 | * Adapting code for this framework will be trivial or easy.
11 |
12 | [h3]Analysis[/h3]
13 | What prevents smooth working with Follow Mode is the use by lisp code of certain primitives which directly access window features. These primitives include (but may not be limited to):
14 | * window-start
15 | * window-end
16 | * set-window-start
17 | * recenter
18 | * pos-visible-in-window-p
19 | * move-to-window-line
20 |
21 | [h3]The proposal[/h3]
22 | The idea is to add an optional argument to each of the above primitives. If non-nil, the argument means "should Follow Mode be active, please operate on the entire Follow Mode group of windows as if it were a single window; otherwise, please operate on the single window only". If the argument is nil, it means "please operate on the single window supplied, even if Follow Mode is active". The new argument will be called "group".
23 |
24 | In addition to the above, functionality is occasionally needed to give access to all the Follow Mode windows as a list (or a single window in a list). This function will be called
25 | * selected-window-group
26 |
27 | [h3]The mechanism[/h3]
28 | For each of the seven functions identified above, a permanent local buffer local variable will be created; this will be nil except when Follow Mode is active, when it will hold a function to execute instead of the standard functionality. These variables will be named "window-start-group-function", etc. Each of the seven functions will recognise that Follow Mode is active by testing whether its ...-group-function variable is a function. If so, it will call that function and return its result. Typically, this function will call the original primitive recursively.
29 |
30 | When Follow Mode is started, these buffer local variables will get set to Follow Mode functions which perform the desired actions on the whole group of windows. When Follow Mode is terminated, these variables become nil again.
31 |
32 | [h3]Documentation[/h3]
33 | The necessary amenements to the Emacs Lisp manual will be mainly in the "Windows" section. In "Basic Windows" the concept "group of windows" will be defined, together with the documentaition of the new function selected-window-group. In the documentation of each of the pertinent seven functions, the extra argument "group" will be described, together with the use of the new variable "...-group-function".
34 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/MozRepl:
--------------------------------------------------------------------------------
1 | Remote read-eval-print-loop to access and modify Mozilla and Firefox apps from the inside. Comes with a minor mode for Emacs integration.
2 |
3 | * MozRepl: http://wiki.github.com/bard/mozrepl
4 | * Movie: http://www.youtube.com/watch?v=5RSnHN6S52c
5 | * Emacs Integration: http://wiki.github.com/bard/mozrepl/emacs-integration
6 | ** NOTE: instructions link to 2.0 Beta 8 (from Dec 2006) version of javascript.el; we're up to at least 2.2.1 as of Dec, 2008
7 | * Main project: http://hyperstruct.net/projects/mozlab
8 |
9 | == Live-Preview: Mirror buffer changes instantly in the browser ==
10 | moz-reload-mode: http://gist.github.com/442376
11 |
12 | [NxhtmlMode nXhtml] also features a MozRepl powered live preview of the edited buffer.
13 | This includes also a possibility to display in the browser point where you are in the editing buffer.
14 |
15 | New since some months in nXhtml are the ability to see search matches from isearch and re-builder too. (But this is yet only in the Launchpad repositories for nXhtml and you will need the updated re-builder there.)
16 |
17 | This support in nXhtml can however probably be made much better and faster by someone who knows more about javascript. If someone would like to do that it would be very nice.
18 |
19 | == Automatically Refresh Browser After Saving HTML/CSS files ==
20 |
21 | This snippet triggers a browser refresh every time an .html or .css file is saved in emacs. It uses the emacs MozRepl integration linked to above.
22 |
23 | Notes: There is a one-second delay before refreshing the browser. That is set in the: setTimeout(BrowserReload(), "1000"... line. You can change it; it is specified in milliseconds - 1000=1s.
24 |
25 | Also, if you have multiple tabs/windows open it might initially pick the wrong window to refresh - just create a new tab, load the page there and it should start refreshing that tab instead.
26 |
27 |
28 | (defun auto-reload-firefox-on-after-save-hook ()
29 | (add-hook 'after-save-hook
30 | '(lambda ()
31 | (interactive)
32 | (comint-send-string (inferior-moz-process)
33 | "setTimeout(BrowserReload, \"1000\");"))
34 | 'append 'local)) ; buffer-local
35 |
36 | ;; Example - you may want to add hooks for your own modes.
37 | ;; I also add this to python-mode when doing django development.
38 | (add-hook 'html-mode-hook 'auto-reload-firefox-on-after-save-hook)
39 | (add-hook 'css-mode-hook 'auto-reload-firefox-on-after-save-hook)
40 |
41 |
42 | I suggest using below code,
43 |
44 | (comint-send-string (inferior-moz-process)
45 | "setTimeout(function(){content.document.location.reload(true);}, '500');")
46 |
47 | instead of BrowserReload. The difference is this solution won't cache the user input after web page refreshed.
48 |
49 | I got irritated by having the currently focused tab being reloaded so to just reload all tabs that start with the url http://localhost:3000/:
50 |
51 | (comint-send-string (inferior-moz-process) "
52 | var num = gBrowser.browsers.length;
53 | for (var i = 0; i < num; ++i) {
54 | var browser = gBrowser.getBrowserAtIndex(i);
55 | if (browser.currentURI.spec.substr(0, 21) == 'http://localhost:3000')
56 | {
57 | browser.reload();
58 | }
59 | }")
60 |
61 | Change the substr(0, 21) to the length of the new string when changing the url.
62 |
63 | [new]
64 | Nice, but if you are going to experiment with this it might be good to use a named function in the hook instead of a lambda.
65 | That way you can change it and you can also delete it from the hook if you want to.
66 |
67 | == Live-Preview: auto-refresh the browser, improved version==
68 | Make the auto-refresh browser smarter, using below code, which is all you need,
69 |
70 | (defun my-moz-refresh-browser-condition (current-file)
71 | "Should return a boolean javascript expression or nil"
72 | (let (rlt)
73 | (cond
74 | ((string-match "\\(beeta\\|cb_tutorial\\)" current-file)
75 | (setq rlt "content.document.location.href.indexOf(':8001')!==-1"))
76 | (t
77 | (setq rlt nil)))
78 | rlt))
79 |
80 | ;; {{ mozrepl auto-refresh browser
81 | (defun moz-reload-browser ()
82 | (interactive)
83 | (let (js-cond cmd)
84 | (if (fboundp 'my-moz-refresh-browser-condition)
85 | (setq js-cond (funcall 'my-moz-refresh-browser-condition (buffer-file-name))))
86 | (cond
87 | (js-cond
88 | (setq cmd (concat "if(" js-cond "){setTimeout(function(){content.document.location.reload(true);}, '500');}")))
89 | (t
90 | (setq cmd "setTimeout(function(){content.document.location.reload(true);}, '500');")))
91 | (comint-send-string (inferior-moz-process) cmd)
92 | ))
93 |
94 | (defun moz-after-save ()
95 | (interactive)
96 | (when (memq major-mode '(web-mode html-mode nxml-mode nxhml-mode php-mode))
97 | (moz-reload-browser)))
98 |
99 | (add-hook 'after-save-hook
100 | 'moz-after-save
101 | 'append 'local)
102 | ;; }}
103 |
104 |
105 |
106 | == Read/Write DOM element in web page==
107 | * Read http://blog.binchen.org/?p=987 to understand why. there is sample js code there.
108 | * Install latest addon and firefox if possible
109 | * Copy/paste below code into ~/.emacs, then you just need "M-x moz-load-js-file-and-send-it" and select the js file you need execute:
110 |
111 | (defun moz-goto-content-and-run-cmd (cmd)
112 | (comint-send-string (inferior-moz-process)
113 | (concat "repl.enter(content);"
114 | cmd
115 | "repl.back();")))
116 |
117 | (setq moz-repl-js-dir (expand-file-name "~/moz-repl-js-dir"))
118 |
119 | (defun moz--read-file (js-file)
120 | (with-temp-buffer
121 | (insert-file-contents js-file)
122 | (buffer-string)))
123 |
124 | (defun moz-load-js-file-and-send-it ()
125 | "load js file from specific directory and send it to mozrepl"
126 | (interactive)
127 | (let (cmd js-file)
128 | (setq js-file (read-file-name "js file:" moz-repl-js-dir))
129 | (when (file-exists-p js-file)
130 | ;; flush mozrepl at first
131 | (moz-goto-content-and-run-cmd "console.log('hello');")
132 | ;; read the content of js-file
133 | (setq cmd (moz--read-file js-file))
134 | (moz-goto-content-and-run-cmd cmd))
135 | ))
136 |
137 |
138 |
139 | == See Also ==
140 |
141 | JavaScriptMode
142 |
143 | ----
144 | CategoryProgramming
145 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/Proposals:
--------------------------------------------------------------------------------
1 | This page contains links to semi-formal proposals concerning improvements to
2 | the Emacs editor or its packages in ELPA. This is intended for public comment
3 | and discussion, and ease of author revision.
4 |
5 | * [[Isearch-prompt-proposal|Discoverability of isearch options]]
6 | * [[Framework extending window functions for Follow Mode (etc.)]]
7 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/RectangleAdd:
--------------------------------------------------------------------------------
1 | I sometimes have a chart of some kind, a row of prices or anything
2 | like this in my emacs. And then I want to add that. If there is
3 | nothing besides the numbers on the line, you can just prepend (+ and
4 | append ), and C-x C-e will do the adding. But IF there is stuff on the
5 | line... I use rectangle-add. It shows the result in the minibuffer,
6 | and puts it in the kill ring. Have fun.
7 |
8 | (defun rectangle-add (start end)
9 | "Add all the lines in the region-rectangle and put the result in the
10 | kill ring."
11 | (interactive "r")
12 | (let ((sum 0))
13 | (mapc (lambda (line)
14 | (setq sum (+ sum (rectangle-add-make-number line))))
15 | (extract-rectangle start end))
16 | (kill-new (number-to-string sum))
17 | (message "%s" sum)))
18 |
19 | (defun rectangle-add-make-number (n)
20 | "Turn a string into a number, being tolerant of commas and even other
21 | 'junk'.
22 | When I started programming, my numeric input routines translated l
23 | (lowercase ell) into 'one', as many users had learnt their
24 | keyboarding on manual typewriters which typically lacked
25 | a separate key for the digit 1. Am I old, or what?"
26 | (while (string-match "[^0-9.]" n)
27 | (setq n (replace-match "" nil nil n)))
28 | (string-to-number n))
29 |
30 | [new]
31 | Nice. But have you tried [OrgMode Org-mode]'s table editor?
32 |
33 | [new]
34 | See also AddNumbers.
35 |
36 | [new]
37 | See also `M-x calc-grab-sum-down', which is available once the
38 | AdvancedDeskCalculator has been loaded. -- JohnWiegley
39 |
40 | ----
41 | CategoryCalculators
42 | CategoryRegion
43 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/SelectKey:
--------------------------------------------------------------------------------
1 | Martin Cracauer wrote some code which emulates the SELECT key from a Symbolics Lisp machine. EdwardOConnor adapted that some, and here's my adaptation of that along with some keybindings that I commonly use.
2 |
3 |
4 | ;; stesla-f8-prefix-map is a sparse keymap defined earlier in my .emacs
5 | ;;(defvar stesla-select-prefix-map stesla-f8-prefix-map)
6 |
7 | ;; updated 7/30/07 now works with 22.1
8 | (define-prefix-command 'stesla-select-prefix-map)
9 | (global-set-key [f8] stesla-select-prefix-map)
10 |
11 | (global-set-key [menu] stesla-select-prefix-map)
12 | (global-set-key [apps] stesla-select-prefix-map)
13 |
14 | (defun stesla-display-select-bindings ()
15 | (interactive)
16 | (describe-bindings [f8]))
17 |
18 | (define-key stesla-select-prefix-map "?" 'stesla-display-select-bindings)
19 |
20 | (defmacro stesla-define-select-key (fname-base key &optional buf-form else-form)
21 | "Define a select-key function FNAME-BASE bound on KEY.
22 |
23 | If provided, BUF-FORM should be a form which will attempt to return
24 | a buffer to switch to. If it returns nil, ELSE-FORM is evaluated."
25 | (let ((fname (intern (concat "stesla-select-" (symbol-name fname-base)))))
26 | `(progn
27 | (defun ,fname (arg)
28 | (interactive "P")
29 | (let ((buf ,buf-form))
30 | (if buf
31 | (switch-to-buffer buf)
32 | ,else-form)))
33 | (define-key stesla-select-prefix-map ,key ',fname))))
34 |
35 | (put 'stesla-define-select-key 'lisp-indent-function 2)
36 |
37 | (defmacro stesla-define-select-key-class (fname-base key extension &optional default-dir)
38 | `(stesla-define-select-key ,(intern (concat (symbol-name fname-base) "-file")) ,key
39 | (let ((buffers (buffer-list))
40 | (buffer t))
41 | (while (and buffers
42 | (listp buffers))
43 | (setq buffer (car buffers))
44 | (setq buffers (cdr buffers))
45 | (if (string-match ,extension (buffer-name buffer))
46 | (setq buffers nil)
47 | (setq buffer nil)))
48 | buffer)
49 | (find-file
50 | (read-file-name ,(concat "Find " (symbol-name fname-base) " file: ")
51 | ,default-dir))))
52 |
53 | ;; These are the file types I use at least semi-regularly.
54 |
55 | (stesla-define-select-key-class C "c" "\\.c$")
56 | (stesla-define-select-key-class Emacs-Lisp "e" "\\.el$" "~/.elisp/")
57 | (stesla-define-select-key-class HTML "h" "\\.s?html$" "~/www/")
58 | (stesla-define-select-key-class Lisp "l" "\\.\\(lisp\\|lsp\\)$")
59 | (stesla-define-select-key-class LaTeX "t" "\\.tex$")
60 | (stesla-define-select-key-class Makefile "M" "\\(GNU\\)?[Mm]akefile")
61 | (stesla-define-select-key-class m4 "4" "\\.m4$")
62 |
63 | ;; For easy access to a few commonly accessed files/buffers.
64 |
65 | (stesla-define-select-key dotemacs-file "."
66 | (find-buffer-visiting stesla-dotemacs-file)
67 | (find-file stesla-dotemacs-file))
68 |
69 | (stesla-define-select-key home-directory "~"
70 | (find-buffer-visiting "~")
71 | (dired "~"))
72 | ;; That ~ key is impossible to type...
73 | (define-key stesla-select-prefix-map "`" 'stesla-select-home-directory)
74 |
75 | (stesla-define-select-key info "i"
76 | (find-buffer-visiting "*info*")
77 | (info))
78 |
79 | (stesla-define-select-key shell "!"
80 | (find-buffer-visiting "*eshell*")
81 | (eshell))
82 |
83 | (stesla-define-select-key gnus "g"
84 | (gnus))
85 |
86 |
87 | ----
88 |
89 | I've updated this module to be a bit more modern: you can repeat the selection key to cycle through buffers matching the same type. The newer version is at Lisp:selectkey.el. -- JohnWiegley
90 |
--------------------------------------------------------------------------------
/doc/EmacsWiki/UsePackage:
--------------------------------------------------------------------------------
1 | Lisp:use-package.el is a combined installer and configurer, which defines an
2 | "autofetch" (like autoload, but downloading from the network -- or
3 | other media) and also conveniently sets up various things it's useful
4 | to have on eval-after-load forms.
5 |
6 | Its entry point is the macro use-package; you might also want to use autofetch in its own right.
7 |
8 | This lets you write package descriptions such as:
9 |
10 | (use-package vm
11 | nil ; download to default directory
12 | (nil ; use default getter function
13 | "http://www.seanet.com/~kylemonger/vm/vm-7.19.tar.gz"
14 | ;; after-download form:
15 | (shell-command "cd vm-7.19; make"))
16 | ;; configuration arg to use-package:
17 | ("$COMMON/emacs/email" ; string means directory for load-path
18 | (require 'jcgs-vm-stuff) ; can add your own aux stuff
19 | ([ C-f11 ] . js-vm-get-mail) ; key definitions
20 | ([ M-C-f11 ] . vm-continue-composing-message)
21 | ;; autoloads/autofetches
22 | (vm "vm" "Run the VM mail reader" t)
23 | ;; things that look like auto-mode-alist entries are
24 | ("~/vm" . vm-mode)
25 | ("$COMMON/vm" . vm-mode))
26 | ;; remaining args to use-package are eval-after-load forms
27 | (setq vm-mutable-frames nil
28 | bbdb-completion-type 'primary-or-name
29 | read-mail-command 'vm
30 | vm-folder-directory (if (file-directory-p
31 | (expand-file-name "~/vm/"))
32 | (expand-file-name "~/vm/")
33 | (substitute-in-file-name "$COMMON/vm/"))
34 | vm-primary-inbox (expand-file-name "john" vm-folder-directory)))
35 |
36 | I find this a handy way for keeping together definitions of how to get
37 | a package, with how to configure it; it's particularly nice when I
38 | arrive on an unfamiliar machine, and can load one startup file from
39 | the web or my USB key drive, and have it pull the rest across as I use
40 | it for the first time on that machine.
41 |
42 | The next enhancement will probably be indirect URLs, where it searches
43 | the page at the specified URL, for links whose anchor text matches a
44 | particular pattern -- intended for giving it a downloads page such as
45 | on SourceForge, and picking the URL from that. I'll probably add SHA1/
46 | MD5 verirfication, too.
47 |
48 | [new]
49 | I've created something similar to this package, also called
50 | [https://github.com/jwiegley/use-package use-package.el], except that it
51 | focuses only on configuration, not installation or updating. It optionally
52 | links to el-get for that behavior. Further, my version emphasizes startup
53 | performance. -- JohnWiegley
54 |
--------------------------------------------------------------------------------
/gerwinski-gnu-head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwiegley/dot-emacs/5fde10831807587d3dc3476519884165096c00a1/gerwinski-gnu-head.png
--------------------------------------------------------------------------------
/lisp/README.org:
--------------------------------------------------------------------------------
1 | #+TITLE: Emacs Modules written by John Wiegley
2 | #+STARTUP: content
3 |
4 | This directory contains Lisp modules I've written, or maintain, and which are
5 | still actively used. For older modules, see the ../retired directory.
6 |
7 | * Modules
8 |
9 | ** c-includes.el
10 | Perform a regex search through a C/C++ file, and also every file causes to
11 | be included. Displays the output in outline-mode so you can see the
12 | structure of how things are included. It includes a simple preprocessor
13 | and colorizes the results according to whether the matched would be included
14 | in the compilation or not (this part needs a bit more work though).
15 |
16 | ** cl-info.el
17 | Perform a quick HyperSpec lookup in Emacs, using the Info pages. This is
18 | *incredibly* helpful if you've forgotten the exactly syntax to `loop', for
19 | example. Oh wait, I just forgot it again, looking it up in cl-info...
20 |
21 | ** org-devonthink.el
22 | Code for obtaining a URL to the currently selected database item in
23 | DEVONthink, a database program on Mac OS X (and one of my favorite programs
24 | of all time!). You can then use `org-insert-link' to insert the link into
25 | any Org file.
26 |
27 | * Packages
28 |
29 | ** chess
30 | A complete chess client and library (but with only a minimal chess AI).
31 | The main use to play against Crafty, or GnuChess, or online at
32 | freechess.org. It can also be used for working through puzzles, annotating
33 | games, visualizing a PGN file, playing against an Emacs Chess friend on
34 | IRC, and much, much more.
35 |
36 | ** eshell
37 | An operating system shell written entirely in Emacs Lisp. It's main
38 | selling points are excellent integration with Lisp, and the fact that it
39 | works the same on all operating systems that run Emacs, as most are the
40 | core commands (cp, rm, ls, etc.) are in Lisp too.
41 |
42 | ** gnus-harvest
43 | Observe the e-mail addresses that you see while reading and writing e-mail,
44 | and record them all in an SQLite database, along with weighting values and
45 | a time stamp. Then, when you write a message, you can complete against the
46 | most likely candidates for a given substring.
47 |
48 | ** initsplit
49 | Split up your Emacs customizations across multiple files.
50 |
51 | ** muse
52 | An authoring and publishing tool for Emacs. Write in a simplified markup
53 | format -- similar, but not identical to, Markdown -- and then publish to
54 | multiple output formats: HTML, LaTeX, DocBook, and more. Support projects,
55 | the creation of websites, and easy integration of additional backends.
56 |
57 | ** regex-tool
58 | A regular expression workshop for programmers, supporting both Perl and
59 | Emacs Lisp regexp syntax. Basically it creates a new frame with three
60 | windows: one where you type the target data, another where you type the
61 | regexp, and a third that shows the matching groups. The target data gets
62 | color-highlighted as you type, so you can easily find problems in really
63 | complex regexps.
64 |
65 |
66 | #+LINK: gmane http://mid.gmane.org/
67 | #+LINK: emacswiki http://www.emacswiki.org/emacs/
68 |
--------------------------------------------------------------------------------
/lisp/aibo-hack.el:
--------------------------------------------------------------------------------
1 | ;;; aibo-hack.el --- InPlace Diff -*- lexical-binding: t; -*-
2 |
3 | (require 'cl-lib)
4 | (require 'cl-macs)
5 |
6 | (defun gptel-aibo--summon-apply
7 | (point insertion &optional nearby-modification next-predicts)
8 | "Apply INSERTION and NEARBY-MODIFICATION at POINT."
9 | (let* ((buffer (current-buffer))
10 | (insertion-diff-parts
11 | (gptel-aibo--extract-diff-lines (car insertion) (cdr insertion)))
12 | (insertion-diff-lines (car insertion-diff-parts))
13 | (insertion-diff-offsets (cadr insertion-diff-parts))
14 | (nearby-diff-parts
15 | (when nearby-modification
16 | (gptel-aibo--extract-diff-lines
17 | (car nearby-modification) (cdr nearby-modification))))
18 | (nearby-diff-lines
19 | (when nearby-diff-parts (car nearby-diff-parts)))
20 | (nearby-diff-offsets
21 | (when nearby-diff-parts (cadr nearby-diff-parts)))
22 | (insertion-diffs nil)
23 | (nearby-modification-diffs nil)
24 | (insertion-ready nil)
25 | (modification-ready nil))
26 |
27 | (cl-flet
28 | ((maybe-apply-diffs ()
29 | (when (and insertion-ready
30 | (or (not nearby-modification) modification-ready))
31 | (with-current-buffer buffer
32 | (gptel-aibo--summon-apply-with-diffs
33 | point
34 | (list (car insertion)
35 | insertion-diff-offsets
36 | insertion-diff-lines
37 | insertion-diffs)
38 | (when nearby-modification
39 | (list (car nearby-modification)
40 | nearby-diff-offsets
41 | nearby-diff-lines
42 | nearby-modification-diffs))
43 | next-predicts)))))
44 |
45 | (gptel-aibo--inplace-diff
46 | (car insertion-diff-lines)
47 | (cdr insertion-diff-lines)
48 | (lambda (diffs)
49 | (setq insertion-diffs diffs
50 | insertion-ready t)
51 | (maybe-apply-diffs)))
52 |
53 | (when nearby-modification
54 | (gptel-aibo--inplace-diff
55 | (car nearby-diff-lines)
56 | (cdr nearby-diff-lines)
57 | (lambda (diffs)
58 | (setq nearby-modification-diffs diffs
59 | modification-ready t)
60 | (maybe-apply-diffs)))))))
61 |
62 | (provide 'aibo-hack)
63 |
--------------------------------------------------------------------------------
/lisp/copy-code.el:
--------------------------------------------------------------------------------
1 | ;;; copy-code --- Copies highlighted code to the pasteboard as RTF
2 |
3 | ;; Copyright (C) 2011 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 08 Dec 2011
7 | ;; Version: 1.0
8 | ;; Keywords: code clipboard pasteboard
9 | ;; X-URL: https://github.com/jwiegley/copy-code
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; Uses the tool "highlight", and the system utility "pbcopy" to copy the
29 | ;; selected region (or the current buffer) as RTF to the system pasteboard.
30 | ;;
31 | ;; I bind this to M-a-w, or Cmd-Option-W on my Mac. It's great for getting
32 | ;; code from Emacs into Keynote as highlighted text with leading line numbers.
33 | ;;
34 | ;; The command `copy-code-as-rtf' also accepts prefix and numerical arguments:
35 | ;;
36 | ;; C-u M-x copy-code-as-rtf Don't use prefixed line numbers
37 | ;; M-24 M-x copy-code-as-rtf Use a font-size of 24pt
38 | ;; M-- M-24 M-x copy-code-as-rtf Use a font-size of 24pt, and no linnums
39 |
40 | (defgroup copy-code nil
41 | "Copies highlighted code to the pasteboard as RTF"
42 | :group 'prog-mode)
43 |
44 | ;;;###autoload
45 | (defun copy-code-as-rtf (&optional font-size)
46 | (interactive "P")
47 | (let* ((real-font-size
48 | (if (and font-size
49 | (/= (prefix-numeric-value font-size) 4))
50 | (abs font-size)
51 | 36))
52 | (options
53 | (concat "--font \"DejaVu Sans Mono\" "
54 | (format "--font-size %d " real-font-size)
55 | "-O rtf "
56 | "--style breeze "
57 | (if (and font-size
58 | (or (= (prefix-numeric-value font-size) 4)
59 | (< (prefix-numeric-value font-size) 0)))
60 | "--linenumbers" "")))
61 | (temp-buffer (get-buffer-create " *code*")))
62 | (shell-command-on-region
63 | (if (region-active-p) (region-beginning) (point-min))
64 | (if (region-active-p) (region-end) (point-max))
65 | (format "highlight --syntax %s %s"
66 | (file-name-extension (buffer-file-name)) options)
67 | temp-buffer)
68 | (with-current-buffer temp-buffer
69 | (goto-char (point-max))
70 | (when (search-backward "\\par\\pard" nil t)
71 | (delete-region (match-beginning 0) (match-end 0)))
72 | (shell-command-on-region (point-min) (point-max) "pbcopy")
73 | (kill-buffer (current-buffer)))
74 | (message "Copied %s to pasteboard as RTF with font-size of %d"
75 | (if (region-active-p) "region" "file")
76 | real-font-size)))
77 |
78 | (provide 'copy-code)
79 |
80 | ;;; copy-code.el ends here
81 |
--------------------------------------------------------------------------------
/lisp/delimit.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t -*-
2 |
3 | (defun shift (k entry)
4 | (if (eq (nth 0 k) 'outer)
5 | (throw (nth 1 k)
6 | (funcall entry #'(lambda (val)
7 | (funcall (nth 2 k)
8 | (list 'inner val)))))
9 | (nth 1 k)))
10 |
11 | (defun reset (thunk)
12 | (let ((bound (make-symbol "reset--bound")))
13 | (catch bound
14 | (funcall thunk (list 'outer bound thunk)))))
15 |
16 | (reset
17 | #'(lambda (_)
18 | (+ 4 (reset
19 | #'(lambda (p)
20 | (* 2 (shift p #'(lambda (k)
21 | (funcall k (funcall k 4))))))))))
22 | ;; (+ 4 (* 2 (* 2 4)))
23 | ;; => 20
24 |
25 | (reset
26 | #'(lambda (q)
27 | (+ 4 (reset
28 | #'(lambda (_)
29 | (* 2 (shift q #'(lambda (k)
30 | (funcall k (funcall k 4))))))))))
31 | ;; (+ 4 (* 2 (+ 4 (* 2 4))))
32 | ;; => 28
33 |
34 | (let ((data '(1 2 3)))
35 | (reset
36 | #'(lambda (p)
37 | (list 'a 'b (shift p #'(lambda (k)
38 | (append (funcall k 0)
39 | (mapcar (apply-partially k)
40 | data))))))))
41 | ;; => (a b 0
42 | ;; (a b 1)
43 | ;; (a b 2)
44 | ;; (a b 3))
45 |
--------------------------------------------------------------------------------
/lisp/drafts.el:
--------------------------------------------------------------------------------
1 | ;;; drafts.el --- Write text first, act on it after
2 |
3 | ;; Copyright (C) 2023 John Wiegley
4 |
5 | ;; Emacs Lisp Archive Entry
6 | ;; Filename: drafts.el
7 | ;; Version: 1.0
8 | ;; Keywords: text draft productivity
9 | ;; Author: John Wiegley
10 | ;; Maintainer: John Wiegley
11 | ;; Description: Write text first, act on it after
12 | ;; URL: https://github.com/jwiegley/drafts
13 | ;; Compatibility: Emacs28
14 |
15 | ;; This file is not part of GNU Emacs.
16 |
17 | ;; This is free software; you can redistribute it and/or modify it under
18 | ;; the terms of the GNU General Public License as published by the Free
19 | ;; Software Foundation; either version 2, or (at your option) any later
20 | ;; version.
21 | ;;
22 | ;; This is distributed in the hope that it will be useful, but WITHOUT
23 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 | ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 | ;; for more details.
26 | ;;
27 | ;; You should have received a copy of the GNU General Public License
28 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 | ;; MA 02111-1307, USA.
31 |
32 | ;;; Commentary:
33 |
34 | ;; Use case:
35 | ;;
36 | ;; User types `M-x drafts', one of the two things happen:
37 | ;;
38 | ;; 1. If it has been more than `drafts-reset-delay-seconds' since the last
39 | ;; time the latest drafts buffer was visited, a new, empty buffer is
40 | ;; created with major-mode set to `drafts-default-major-mode'.
41 | ;;
42 | ;; 2. If it has been less than that amount of time, revisit the latest drafts
43 | ;; buffer.
44 | ;;
45 | ;; Old, empty drafts buffer are garbage collected.
46 | ;;
47 | ;; Each drafts buffer is associated with a file in the `drafts-directory',
48 | ;; whose name is formed from the timestamp when the draft was created.
49 | ;; Auto-saving is aggresively enabled in these buffers so that they are saved
50 | ;; very often, and also whenever focus moves away from the buffer.
51 | ;;
52 | ;; In the drafts buffer, the following key bindings are available through the
53 | ;; `drafts-mode-map':
54 | ;;
55 | ;; `C-c C-k' :: Kill the current drafts buffer and delete its associated file.
56 | ;; Prompts if `drafts-prompt-before-delete' is non-nil.
57 | ;;
58 | ;; `C-c C-c' :: "Act" on the content of the current drafts buffer. See below.
59 | ;;
60 | ;; When a draft is killed or acted on, the original file containing the draft
61 | ;; is archived to `drafts-archive-directory'. To avoid archiving killed
62 | ;; drafts, set `drafts-archive-when-killed' to `nil'.
63 | ;;
64 | ;; The command `M-x drafts-browse' will open the `drafts-directory' in dired,
65 | ;; so that you can manage or revisit those files directly. Each file bears the
66 | ;; extension ".draft" in order to know that the default major-mode and drafts
67 | ;; minor-mode should be active.
68 |
69 | (eval-when-compile
70 | (require 'cl))
71 |
72 | (defgroup drafts nil
73 | "Edit and act on textual drafts"
74 | :group 'text)
75 |
76 | (defsubst drafts--filter (f args)
77 | (let (result)
78 | (dolist (arg args)
79 | (when (funcall f arg)
80 | (setq result (cons arg result))))
81 | (nreverse result)))
82 |
83 | (defvar drafts-last-visited-time nil)
84 | (make-variable-buffer-local 'drafts-last-visited-time)
85 |
86 | (defun drafts-last-visited-time ()
87 | (sort
88 | (mapcar
89 | #'(lambda (buf)
90 | (cons buf
91 | (with-current-buffer buf
92 | drafts-last-visited-time)))
93 | (drafts--filter
94 | #'(lambda (buf)
95 | (string-match "\\*drafts\\*" (buffer-name buf)))
96 | (buffer-list)))
97 | #'(lambda (x y)
98 | (> (cdr x) (cdr y)))))
99 |
100 | (define-minor-mode drafts-mode
101 | "Minor mode active in drafts buffers."
102 | :lighter " drafts"
103 | :global t
104 | :group 'drafts
105 | (add-hook 'post-command-hook
106 | #'(lambda (&rest _ignore)
107 | (setq drafts-last-visited-time (current-time)))
108 | nil t))
109 |
110 | (defun drafts (&optional arg)
111 | (interactive "p")
112 | (if (or (not drafts-last-visited-time)
113 | (> (float-time
114 | (time-subtract (current-time)
115 | drafts-last-visited-time))
116 | 30.0))
117 | t
118 | t))
119 |
120 | (provide 'drafts)
121 |
--------------------------------------------------------------------------------
/lisp/dsel-example.el:
--------------------------------------------------------------------------------
1 | (dsel-defsignature
2 | my/org-date-from-query-sig
3 | "Generate org-mode time-string based on user query"
4 | :input-fields '((:name now :type string :desc "Current time in Org mode format")
5 | (:mame query :type string :desc "User query for an Org mode date"))
6 | :output-fields '((:name error :type string :desc "Error message if input query is invalid" :optional t)
7 | (:name time-string :type string :desc "Scheduled task in Org mode format")))
8 |
9 | (dsel-defexamples
10 | my/org-date-from-query-examples ‘(query now)
11 | (:now "[2025-05-25 Sun 22:55]" :query "tm 2pm" :time-string "<2025-05-26 Mon 14:00>")
12 | (:now "[2025-05-25 Sun 22:55]" :query "nx tu 215pm" :time-string "<2025-06-03 Tue 14:15>")
13 | (:now "[2025-@5-25 Sun 22:55]" :query "noon jul 9" :time-string "<2025-07-09 Tue 12:00>"))
14 |
15 | (dsel-defchain-of-thought my/org-date-from-query my/org-date-from-query-sig
16 | :demos my/org-date-from-query-examples
17 | :config '(:temperature Q@.1))
18 |
19 | (defun my/schedule-task (query)
20 | "Schedule a task based on user QUERY."
21 | (interactive "sSchedule task: ")
22 | (let* ((current-time-org (format-time-string "[%Y-%m-%d %a %H:%M]"))
23 | (org-date-pred (dsel-forward my/org-date-from-query :now current-time-org :query query))
24 | (time-string (dsel-get-field org-date-pred 'time-string)))
25 | (unless (and (dsel-prediction-ok-p org-date-pred)
26 | (org-parse-time-string time-string))
27 | (dsel-prediction-report-errors org-date-pred))
28 | (error "Failed to generate org timestamp for query %s predicted sched: %s" query time-string)
29 | (org-schedule nil sched)))
30 |
--------------------------------------------------------------------------------
/lisp/ediff-keep.el:
--------------------------------------------------------------------------------
1 | ;;; ediff-keep --- Commands to help manipulate diff3 regions
2 |
3 | ;; Copyright (C) 2012 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 28 Jun 2012
7 | ;; Version: 1.0
8 | ;; Keywords: ediff diff
9 | ;; X-URL: https://github.com/jwiegley/ediff-keep
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; The module changes Ediff conflicts regions to match the appearance and
29 | ;; meaning of diff3, plus adds an "x" key prefix in the Ediff Control Panel
30 | ;; for picking two or three out of the displayed regions.
31 | ;;
32 | ;; For example:
33 | ;;
34 | ;; a Select region A
35 | ;; b Select region B
36 | ;; x a Exclude region A (keep ancestor and B)
37 | ;; x b Exclude region B (keep ancestor and A)
38 | ;; x c Exclude ancestor (keep A and B)
39 | ;;
40 | ;; I recommend using Smerge mode for direct editing of diff3 output files:
41 | ;;
42 | ;; (add-hook 'diff-mode-hook 'smerge-mode)
43 | ;;
44 | ;; Also, to remain sane, change Ediff's merge display to be the same as diff3:
45 | ;;
46 | ;; (setq ediff-combination-pattern
47 | ;; '("<<<<<<< A: HEAD" A "||||||| Ancestor" Ancestor
48 | ;; "=======" B ">>>>>>> B: Incoming"))
49 |
50 | (require 'ediff)
51 | (require 'ediff-init)
52 | (require 'bind-key)
53 |
54 | (defgroup ediff-keep nil
55 | "Commands to help manipulate diff3 regions"
56 | :group 'ediff-merge)
57 |
58 | (defun ediff-keep-identify-conflicts ()
59 | (interactive)
60 | (with-current-buffer (or ediff-buffer-C
61 | (current-buffer))
62 | (let ((result (list (cons t t)
63 | (cons t t)
64 | (cons t t)
65 | (cons t t))))
66 | (beginning-of-line)
67 | (when (or (looking-at "<<<<<<")
68 | (re-search-backward "^<<<<<<" nil t)
69 | (re-search-forward "^<<<<<<" nil t))
70 | (beginning-of-line)
71 | (setcar (nth 0 result) (point-marker))
72 | (forward-line)
73 | (setcdr (nth 0 result) (point-marker))
74 |
75 | (re-search-forward "^|||||||")
76 | (beginning-of-line)
77 | (setcar (nth 1 result) (point-marker))
78 | (forward-line)
79 | (setcdr (nth 1 result) (point-marker))
80 |
81 | (re-search-forward "^=======")
82 | (beginning-of-line)
83 | (setcar (nth 2 result) (point-marker))
84 | (forward-line)
85 | (setcdr (nth 2 result) (point-marker))
86 |
87 | (re-search-forward "^>>>>>>>")
88 | (beginning-of-line)
89 | (setcar (nth 3 result) (point-marker))
90 | (forward-line)
91 | (setcdr (nth 3 result) (point-marker))
92 |
93 | result))))
94 |
95 | ;; These three functions duplicate part of what smerge-mode does. They are
96 | ;; here for completeness' sake.
97 | (defun ediff-keep-head ()
98 | (interactive)
99 | (let ((marks (ediff-keep-identify-conflicts)))
100 | (delete-region (car (nth 1 marks)) (cdr (nth 3 marks)))
101 | (delete-region (car (nth 0 marks)) (cdr (nth 0 marks)))))
102 |
103 | (defun ediff-keep-ancestor ()
104 | (interactive)
105 | (let ((marks (ediff-keep-identify-conflicts)))
106 | (delete-region (car (nth 2 marks)) (cdr (nth 3 marks)))
107 | (delete-region (car (nth 0 marks)) (cdr (nth 1 marks)))))
108 |
109 | (defun ediff-keep-incoming ()
110 | (interactive)
111 | (let ((marks (ediff-keep-identify-conflicts)))
112 | (delete-region (car (nth 3 marks)) (cdr (nth 3 marks)))
113 | (delete-region (car (nth 0 marks)) (cdr (nth 2 marks)))))
114 |
115 | (defun ediff-keep-head-and-ancestor ()
116 | (interactive)
117 | (let ((marks (ediff-keep-identify-conflicts)))
118 | (delete-region (car (nth 2 marks)) (cdr (nth 3 marks)))
119 | (delete-region (car (nth 1 marks)) (cdr (nth 1 marks)))
120 | (delete-region (car (nth 0 marks)) (cdr (nth 0 marks)))))
121 |
122 | (defun ediff-keep-head-and-incoming ()
123 | (interactive)
124 | (let ((marks (ediff-keep-identify-conflicts)))
125 | (delete-region (car (nth 3 marks)) (cdr (nth 3 marks)))
126 | (delete-region (car (nth 1 marks)) (cdr (nth 2 marks)))
127 | (delete-region (car (nth 0 marks)) (cdr (nth 0 marks)))))
128 |
129 | (defun ediff-keep-ancestor-and-incoming ()
130 | (interactive)
131 | (let ((marks (ediff-keep-identify-conflicts)))
132 | (delete-region (car (nth 3 marks)) (cdr (nth 3 marks)))
133 | (delete-region (car (nth 2 marks)) (cdr (nth 2 marks)))
134 | (delete-region (car (nth 0 marks)) (cdr (nth 1 marks)))))
135 |
136 | (defun ediff-keep-combine-all ()
137 | (interactive)
138 | (let ((marks (ediff-keep-identify-conflicts)))
139 | (delete-region (car (nth 3 marks)) (cdr (nth 3 marks)))
140 | (delete-region (car (nth 2 marks)) (cdr (nth 3 marks)))
141 | (delete-region (car (nth 1 marks)) (cdr (nth 1 marks)))
142 | (delete-region (car (nth 0 marks)) (cdr (nth 0 marks)))))
143 |
144 | (add-hook 'ediff-keymap-setup-hook
145 | #'(lambda ()
146 | (bind-key "x" nil ediff-mode-map)
147 | (bind-key "x h" 'ediff-keep-ancestor-and-incoming ediff-mode-map)
148 | (bind-key "x a" 'ediff-keep-head-and-incoming ediff-mode-map)
149 | (bind-key "x i" 'ediff-keep-head-and-ancestor ediff-mode-map)
150 | (bind-key "x c" 'ediff-keep-combine-all ediff-mode-map)))
151 |
152 | (provide 'ediff-keep)
153 |
154 | ;;; ediff-keep.el ends here
155 |
--------------------------------------------------------------------------------
/lisp/edit-rectangle.el:
--------------------------------------------------------------------------------
1 | (defvar edit-rectangle-origin)
2 | (defvar edit-rectangle-saved-window-config)
3 |
4 | (defun edit-rectangle (&optional start end)
5 | (interactive "r")
6 | (let ((strs (delete-extract-rectangle start end))
7 | (mode major-mode)
8 | (here (copy-marker (min (mark) (point)) t))
9 | (config (current-window-configuration)))
10 | (with-current-buffer (generate-new-buffer "*Rectangle*")
11 | (funcall mode)
12 | (set (make-local-variable 'edit-rectangle-origin) here)
13 | (set (make-local-variable 'edit-rectangle-saved-window-config) config)
14 | (local-set-key (kbd "C-c C-c") #'restore-rectangle)
15 | (mapc #'(lambda (x) (insert x ?\n)) strs)
16 | (goto-char (point-min))
17 | (pop-to-buffer (current-buffer)))))
18 |
19 | (defun restore-rectangle ()
20 | (interactive)
21 | (let ((content (split-string (buffer-string) "\n"))
22 | (origin edit-rectangle-origin)
23 | (config edit-rectangle-saved-window-config))
24 | (with-current-buffer (marker-buffer origin)
25 | (goto-char origin)
26 | (insert-rectangle content))
27 | (kill-buffer (current-buffer))
28 | (set-window-configuration config)))
29 |
30 | (provide 'edit-rectangle)
31 |
--------------------------------------------------------------------------------
/lisp/emacs-edg/README.md:
--------------------------------------------------------------------------------
1 | emacs-edg
2 | =========
3 |
4 | Emacs Lisp support for working on EDG source code
--------------------------------------------------------------------------------
/lisp/emacs-edg/edg.el:
--------------------------------------------------------------------------------
1 | (require 'cc-mode)
2 | (require 'yasnippet)
3 |
4 | (add-to-list 'c-style-alist
5 | '("edg"
6 | (indent-tabs-mode . nil)
7 | (c-basic-offset . 2)
8 | (c-comment-only-line-offset . (0 . 0))
9 | (c-hanging-braces-alist
10 | . ((substatement-open before after)
11 | (arglist-cont-nonempty)))
12 | (c-offsets-alist
13 | . ((statement-block-intro . +)
14 | (knr-argdecl-intro . 5)
15 | (substatement-open . 0)
16 | (substatement-label . 0)
17 | (label . 0)
18 | (case-label . +)
19 | (statement-case-open . 0)
20 | (statement-cont . +)
21 | (arglist-intro . +)
22 | (arglist-close . +)
23 | (inline-open . 0)
24 | (brace-list-open . 0)
25 | (topmost-intro-cont
26 | . (first c-lineup-topmost-intro-cont
27 | c-lineup-gnu-DEFUN-intro-cont))))
28 | (c-special-indent-hook . c-gnu-impose-minimum)
29 | (c-block-comment-prefix . "")))
30 |
31 | (define-minor-mode edg-mode
32 | "Minor mode for editing EDG code.")
33 |
34 | (yas/define-snippets
35 | 'cc-mode
36 | '(("if" "if ($0) {\n} /* if */" "if" edg-mode)
37 |
38 | ("ife" "if ($0) {\n} else {\n} /* if */" "ife" edg-mode)
39 |
40 | ("switch"
41 | "switch ($0) {\ncase :\nbreak;\ndefault:\nbreak;\n} /* switch */"
42 | "switch" edg-mode)
43 |
44 | ("for" "for ($0; ; ) {\n} /* for */" "for" edg-mode)
45 |
46 | ("while" "while ($0) {\n} /* while */" "while" edg-mode)
47 |
48 | ("defun" "void $1($0) {\n} /* $1 */" "defun" edg-mode)
49 | ))
50 |
51 | (provide 'edg)
52 |
--------------------------------------------------------------------------------
/lisp/erc-alert.el:
--------------------------------------------------------------------------------
1 | ;;; erc-alert --- Alert me using alert.el for important ERC messages
2 |
3 | ;; Copyright (C) 2011 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 20 Sep 2011
7 | ;; Version: 1.0
8 | ;; Keywords: erc alert irc
9 | ;; X-URL: https://github.com/jwiegley/dot-emacs
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; Notify me using alert.el when people talk to me in ERC.
29 |
30 | (require 'erc)
31 | (require 'alert)
32 |
33 | (defgroup erc-alert nil
34 | "Alert me using alert.el for important ERC messages"
35 | :group 'erc)
36 |
37 | (defcustom erc-priority-people-regexp ".*"
38 | "Regexp that matches BitlBee users you want active notification for."
39 | :type 'regexp
40 | :group 'erc-alert)
41 |
42 | (defcustom erc-growl-noise-regexp
43 | (concat "\\(Logging in:\\|Signing off\\|You're now away"
44 | "\\|Welcome back\\|Setting automatically away\\)")
45 | "This regexp matches unwanted noise."
46 | :type 'regexp
47 | :group 'erc-alert)
48 |
49 | (defun erc-alert-important-p (info)
50 | (let ((message (plist-get info :message))
51 | (erc-message (plist-get info :data)))
52 | (and erc-message
53 | (not (or (string-match "^\\** *Users on #" message)
54 | (string-match erc-growl-noise-regexp
55 | message))))))
56 |
57 | (defun my-erc-hook (&optional match-type nick message)
58 | "Shows a growl notification, when user's nick was mentioned.
59 | If the buffer is currently not visible, makes it sticky."
60 | (if (or (null match-type) (not (eq match-type 'fool)))
61 | (let (alert-log-messages)
62 | (alert (or message (buffer-string)) :severity 'high
63 | :title (concat "ERC: " (or nick (buffer-name)))
64 | :data message))))
65 |
66 | (add-hook 'erc-text-matched-hook 'my-erc-hook)
67 | (add-hook 'erc-insert-modify-hook 'my-erc-hook)
68 |
69 | (defun my-erc-define-alerts (&rest ignore)
70 | ;; Unless the user has recently typed in the ERC buffer, highlight the fringe
71 | (alert-add-rule
72 | :status '(buried visible idle)
73 | :severity '(moderate high urgent)
74 | :mode 'erc-mode
75 | :predicate
76 | #'(lambda (info)
77 | (and (not (eq (current-buffer) (plist-get info :buffer)))
78 | (or (string-match "johnw:" (plist-get info :message))
79 | (string-match (concat "\\`[^&]" erc-priority-people-regexp
80 | "@BitlBee\\'")
81 | (erc-format-target-and/or-network)))))
82 | :persistent
83 | #'(lambda (info)
84 | ;; If the buffer is buried, or the user has been idle for
85 | ;; `alert-reveal-idle-time' seconds, make this alert
86 | ;; persistent. Normally, alerts become persistent after
87 | ;; `alert-persist-idle-time' seconds.
88 | (memq (plist-get info :status) '(buried idle)))
89 | :style 'fringe
90 | :continue t)
91 |
92 | ;; If the ERC buffer is not visible, tell the user through Growl
93 | (alert-add-rule
94 | :status 'buried
95 | :mode 'erc-mode
96 | :predicate #'erc-alert-important-p
97 | :style (if (file-executable-p alert-notifier-command)
98 | 'notifier
99 | 'growl)
100 | :append t)
101 |
102 | (alert-add-rule
103 | :status 'buried
104 | :mode 'erc-mode
105 | :predicate #'erc-alert-important-p
106 | :style 'message
107 | :append t)
108 |
109 | (alert-add-rule
110 | :mode 'erc-mode
111 | :predicate #'erc-alert-important-p
112 | :style 'log
113 | :append t)
114 |
115 | (alert-add-rule :mode 'erc-mode :style 'ignore :append t))
116 |
117 | (add-hook 'erc-connect-pre-hook 'my-erc-define-alerts)
118 |
119 | (provide 'erc-alert)
120 |
121 | ;;; erc-alert.el ends here
122 |
--------------------------------------------------------------------------------
/lisp/erc-macros.el:
--------------------------------------------------------------------------------
1 | (require 'erc)
2 | (eval-when-compile
3 | (require 'cl)
4 | (defvar erc-fools))
5 |
6 | (defun erc-cmd-FOOL (term &rest ignore)
7 | (add-to-list 'erc-fools term))
8 |
9 | (defun erc-cmd-UNFOOL (term &rest ignore)
10 | (setq erc-fools (delete term erc-fools)))
11 |
12 | (defun erc-cmd-OPME ()
13 | "Request chanserv to op me."
14 | (erc-message "PRIVMSG"
15 | (format "chanserv op %s %s"
16 | (erc-default-target)
17 | (erc-current-nick)) nil))
18 |
19 | (defun erc-cmd-DEOPME ()
20 | "Deop myself from current channel."
21 | (erc-cmd-DEOP (format "%s" (erc-current-nick))))
22 |
23 | (defun erc-cmd-BAN (nick &optional redirect whole-ip)
24 | (let* ((chan (erc-default-target))
25 | (who (erc-get-server-user nick))
26 | (host (erc-server-user-host who))
27 | (user (erc-server-user-login who)))
28 | (erc-send-command
29 | (format "MODE %s +b *!%s@%s%s"
30 | chan (if whole-ip "*" user) host (or redirect "")))))
31 |
32 | (defun erc-cmd-KICKBAN (nick &rest reason)
33 | (setq reason (mapconcat #'identity reason " "))
34 | (and (string= reason "")
35 | (setq reason nil))
36 | (erc-cmd-OPME)
37 | (sleep-for 0 250)
38 | (erc-cmd-BAN nick)
39 | (erc-send-command (format "KICK %s %s %s"
40 | (erc-default-target)
41 | nick
42 | (or reason
43 | "Kicked (kickban)")))
44 | (sleep-for 0 250)
45 | (erc-cmd-DEOPME))
46 |
47 | (defun erc-cmd-QUIET (nick)
48 | (erc-cmd-OPME)
49 | (sleep-for 0 250)
50 | (erc-send-command (format "QUIET %s %s"
51 | (erc-default-target)
52 | nick))
53 | (sleep-for 0 250)
54 | (erc-cmd-DEOPME))
55 |
56 | (defun erc-cmd-KICKBANIP (nick &rest reason)
57 | (setq reason (mapconcat #'identity reason " "))
58 | (and (string= reason "")
59 | (setq reason nil))
60 | (erc-cmd-OPME)
61 | (sleep-for 0 250)
62 | (erc-cmd-BAN nick nil t)
63 | (erc-send-command (format "KICK %s %s %s"
64 | (erc-default-target)
65 | nick
66 | (or reason
67 | "Kicked (kickbanip)")))
68 | (sleep-for 0 250)
69 | (erc-cmd-DEOPME))
70 |
71 | (defun erc-cmd-KICKTROLL (nick &rest reason)
72 | (setq reason (mapconcat #'identity reason " "))
73 | (and (string= reason "")
74 | (setq reason nil))
75 | (erc-cmd-OPME)
76 | (sleep-for 0 250)
77 | (erc-cmd-BAN nick "$#haskell-ops")
78 | (erc-send-command (format "KICK %s %s %s"
79 | (erc-default-target)
80 | nick
81 | (or reason
82 | "Kicked (kicktroll)")))
83 | (sleep-for 0 250)
84 | (erc-cmd-DEOPME))
85 |
86 | ;; this is essentially a refactored `erc-cmd-KICK'
87 | (defun erc-cmd-REMOVE (target &optional reason-or-nick &rest reasonwords)
88 | "Remove a user from the default or specified channel.
89 | LINE has the format: \"#CHANNEL NICK REASON\" or \"NICK REASON\"."
90 | (let* ((target-channel-p (erc-channel-p target))
91 | (channel (if target-channel-p target (erc-default-target)))
92 | (nick (if target-channel-p reason-or-nick target))
93 | (reason
94 | (mapconcat 'identity
95 | (or (if target-channel-p reasonwords
96 | (and reason-or-nick
97 | (cons reason-or-nick reasonwords)))
98 | `("Requested by" ,(erc-current-nick)))
99 | " "))
100 | (server-command (format "REMOVE %s %s :%s" channel nick reason)))
101 | (if (not channel)
102 | (erc-display-message nil 'error (current-buffer)
103 | 'no-default-channel)
104 | (erc-log (format "cmd: REMOVE: %s/%s: %s" channel nick reason))
105 | (erc-server-send server-command))))
106 |
107 | (defun erc-cmd-UNTRACK (&optional target)
108 | "Add TARGET to the list of target to be tracked."
109 | (if target
110 | (erc-with-server-buffer
111 | (let ((untracked
112 | (car (erc-member-ignore-case target erc-track-exclude))))
113 | (if untracked
114 | (erc-display-line
115 | (erc-make-notice
116 | (format "%s is not currently tracked!" target))
117 | 'active)
118 | (add-to-list 'erc-track-exclude target)
119 | (erc-display-line
120 | (erc-make-notice (format "Now not tracking %s" target))
121 | 'active))))
122 |
123 | (if (null erc-track-exclude)
124 | (erc-display-line
125 | (erc-make-notice "Untracked targets list is empty") 'active)
126 |
127 | (erc-display-line (erc-make-notice "Untracked targets list:") 'active)
128 | (mapc #'(lambda (item)
129 | (erc-display-line (erc-make-notice item) 'active))
130 | (erc-with-server-buffer erc-track-exclude))))
131 | t)
132 |
133 | (defun erc-cmd-TRACK (target)
134 | "Remove TARGET of the list of targets which they should not be tracked.
135 | If no TARGET argument is specified, list contents of `erc-track-exclude'."
136 | (when target
137 | (erc-with-server-buffer
138 | (let ((tracked
139 | (not (car (erc-member-ignore-case target erc-track-exclude)))))
140 | (if tracked
141 | (erc-display-line
142 | (erc-make-notice (format "%s is currently tracked!" target))
143 | 'active)
144 | (setq erc-track-exclude (remove target erc-track-exclude))
145 | (erc-display-line
146 | (erc-make-notice (format "Now tracking %s" target))
147 | 'active)))))
148 | t)
149 |
150 | (defun erc-cmd-HOWMANY (&rest ignore)
151 | "Display how many users (and ops) the current channel has."
152 | (erc-display-message
153 | nil 'notice (current-buffer)
154 | (let ((hash-table (with-current-buffer
155 | (erc-server-buffer)
156 | erc-server-users))
157 | (users 0)
158 | (ops 0))
159 | (maphash (lambda (k v)
160 | (when (member (current-buffer)
161 | (erc-server-user-buffers v))
162 | (incf users))
163 | (when (erc-channel-user-op-p k)
164 | (incf ops)))
165 | hash-table)
166 | (format
167 | "There are %s users (%s ops) on the current channel"
168 | users ops))))
169 |
170 | (provide 'erc-macros)
171 |
--------------------------------------------------------------------------------
/lisp/erc-patch.el:
--------------------------------------------------------------------------------
1 | (require 'erc)
2 |
3 | ;; This file make erc-scrolltobottom work again in Emacs 24.
4 |
5 | (defun erc-display-line-1 (string buffer)
6 | "Display STRING in `erc-mode' BUFFER.
7 | Auxiliary function used in `erc-display-line'. The line gets filtered to
8 | interpret the control characters. Then, `erc-insert-pre-hook' gets called.
9 | If `erc-insert-this' is still t, STRING gets inserted into the buffer.
10 | Afterwards, `erc-insert-modify' and `erc-insert-post-hook' get called.
11 | If STRING is nil, the function does nothing."
12 | (when string
13 | (with-current-buffer (or buffer (process-buffer erc-server-process))
14 | (let ((insert-position (or (marker-position erc-insert-marker)
15 | (point-max))))
16 | (let ((string string) ;; FIXME! Can this be removed?
17 | (buffer-undo-list t)
18 | (inhibit-read-only t))
19 | (unless (string-match "\n$" string)
20 | (setq string (concat string "\n"))
21 | (when (erc-string-invisible-p string)
22 | (erc-put-text-properties 0 (length string)
23 | '(invisible intangible) string)))
24 | (erc-log (concat "erc-display-line: " string
25 | (format "(%S)" string) " in buffer "
26 | (format "%s" buffer)))
27 | (setq erc-insert-this t)
28 | (run-hook-with-args 'erc-insert-pre-hook string)
29 | (if (null erc-insert-this)
30 | ;; Leave erc-insert-this set to t as much as possible. Fran
31 | ;; Litterio has seen erc-insert-this set to nil while
32 | ;; erc-send-pre-hook is running, which should never happen. This
33 | ;; may cure it.
34 | (setq erc-insert-this t)
35 | (save-excursion ;; to restore point in the new buffer
36 | (save-restriction
37 | (widen)
38 | (goto-char insert-position)
39 | (insert-before-markers string)
40 | ;; run insertion hook, with point at restored location
41 | (save-restriction
42 | (narrow-to-region insert-position (point))
43 | (run-hooks 'erc-insert-modify-hook)
44 | (run-hooks 'erc-insert-post-hook)
45 | (when erc-remove-parsed-property
46 | (remove-text-properties (point-min) (point-max)
47 | '(erc-parsed nil))))))))
48 | (erc-update-undo-list (- (or (marker-position erc-insert-marker)
49 | (point-max))
50 | insert-position)))
51 | ;;; this line and only this line was added --v
52 | (run-hooks 'erc-display-post-hook))))
53 |
54 | (defvar erc-display-post-hook nil
55 | "New hook!")
56 |
57 | (defun damd-erc-display-post-hook ()
58 | (let ((windows (get-buffer-window-list (current-buffer) nil 'visible)))
59 | (dolist (w windows)
60 | (when (>= (point) erc-input-marker)
61 | (with-selected-window w
62 | (recenter -1))))))
63 | (add-hook 'erc-display-post-hook 'damd-erc-display-post-hook)
64 |
65 | (defun damd-erc-send-post-hook ()
66 | (when (>= (point) erc-input-marker)
67 | (goto-char (point-max))
68 | (widen)
69 | (recenter -1)))
70 | (add-hook 'erc-send-post-hook 'damd-erc-send-post-hook)
71 |
72 | (defun damd-window-configuration-change-hook ()
73 | (when (and (eq major-mode 'erc-mode)
74 | (>= (point) erc-input-marker))
75 | (recenter -1)))
76 |
77 | (add-hook 'window-configuration-change-hook
78 | 'damd-window-configuration-change-hook)
79 |
80 | (provide 'erc-patch)
81 |
--------------------------------------------------------------------------------
/lisp/erc-question.el:
--------------------------------------------------------------------------------
1 | ;;; erc-question --- Ask Google before asking on IRC
2 |
3 | ;; Copyright (C) 2017 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 5 Nov 2017
7 | ;; Version: 1.0
8 | ;; Keywords: erc irc google
9 | ;; X-URL: https://github.com/jwiegley/erc-question
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; If you ask a question in ERC ending with ? and hit RET, it will instead
29 | ;; submit the query to Google using your browser. If you return to ERC and
30 | ;; hit RET a second time (with no intervening commands), then it submits the
31 | ;; question.
32 |
33 | ;;; Code:
34 |
35 | (defgroup erc-question nil
36 | "Ask Google before asking IRC"
37 | :group 'erc)
38 |
39 | (defvar erc-question--last-asked nil)
40 | (defvar erc-question--mode t)
41 |
42 | (defun erc-cmd-ASKON (&rest ignore)
43 | (setq erc-question--mode t)
44 | (message "Queries now go to Google; use ?ask to submit the question"))
45 |
46 | (defun erc-cmd-ASKOFF (&rest ignore)
47 | (setq erc-question--mode nil)
48 | (message "Queries now go to IRC"))
49 |
50 | (defun erc-question (input)
51 | "Ask Google before asking IRC"
52 | (make-variable-buffer-local 'erc-question--last-asked)
53 | (when erc-question--mode
54 | (let ((len (1- (length input))))
55 | (cond
56 | ((string= input "?ask")
57 | (setq str erc-question--last-asked
58 | erc-question--last-asked nil))
59 | ((string-match "\\`\\(.+?\\)\\?\\'" input)
60 | (browse-url (concat "https://www.google.com/search?q="
61 | (url-encode-url (match-string 1 input))))
62 | (setq erc-send-this nil
63 | erc-question--last-asked input))))))
64 |
65 | ;; (add-hook 'erc-send-pre-hook 'erc-question)
66 |
67 | (defun erc-cmd-G (name &rest ignore)
68 | (when (re-search-backward
69 | (concat "<" name "> \\(\\(.\\|\n\\)+\\)\\?") nil t)
70 | (browse-url
71 | (concat "https://www.google.com/search?q="
72 | (url-encode-url
73 | (subst-char-in-string ?\n ?\ (match-string 1)))))))
74 |
75 | (provide 'erc-question)
76 |
77 | ;;; erc-question.el ends here
78 |
--------------------------------------------------------------------------------
/lisp/esh-toggle.el:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwiegley/dot-emacs/5fde10831807587d3dc3476519884165096c00a1/lisp/esh-toggle.el
--------------------------------------------------------------------------------
/lisp/eshell-ext-30.1.el:
--------------------------------------------------------------------------------
1 | (defun eshell-exec-lisp (printer errprint func-or-form args form-p)
2 | "Execute a Lisp FUNC-OR-FORM, maybe passing ARGS.
3 | PRINTER and ERRPRINT are functions to use for printing regular
4 | messages and errors, respectively. FORM-P should be non-nil if
5 | FUNC-OR-FORM represent a Lisp form; ARGS will be ignored in that
6 | case."
7 | (eshell-condition-case err
8 | (let ((result
9 | (save-current-buffer
10 | (if form-p
11 | (eval func-or-form)
12 | (apply func-or-form args)))))
13 | ;; As a special case, a Lisp function or form may evaluate to an
14 | ;; `eshell-function-target', which represents a virtual output
15 | ;; device. In that case, any output piped to the lisp command
16 | ;; will be fed to that function. This makes it possible to use
17 | ;; Lisp commands on the right-hand side of a pipeline.
18 | (if (and result (not (eshell-function-target-p result)))
19 | (funcall printer result))
20 | result)
21 | (eshell-pipe-broken
22 | ;; If FUNC-OR-FORM tried and failed to write some output to a
23 | ;; process, it will raise an `eshell-pipe-broken' signal (this is
24 | ;; analogous to SIGPIPE on POSIX systems). In this case, set the
25 | ;; command status to some non-zero value to indicate an error; to
26 | ;; match GNU/Linux, we use 141, which the numeric value of
27 | ;; SIGPIPE on GNU/Linux (13) with the high bit (2^7) set.
28 | (setq eshell-last-command-status 141)
29 | nil)
30 | (error
31 | (setq eshell-last-command-status 1)
32 | (let ((msg (error-message-string err)))
33 | (if (and (not form-p)
34 | (string-match "^Wrong number of arguments" msg)
35 | (fboundp 'eldoc-get-fnsym-args-string))
36 | (let ((func-doc (eldoc-get-fnsym-args-string func-or-form)))
37 | (setq msg (format "usage: %s" func-doc))))
38 | (funcall errprint msg))
39 | nil)))
40 |
41 | (defun eshell-lisp-command (object &optional args)
42 | "Insert Lisp OBJECT, using ARGS if a function."
43 | (unless eshell-allow-commands
44 | (signal 'eshell-commands-forbidden '(lisp)))
45 | (catch 'eshell-external ; deferred to an external command
46 | (setq eshell-last-command-status 0
47 | eshell-last-arguments args)
48 | (let* ((eshell-ensure-newline-p t)
49 | (command-form-p (functionp object))
50 | (result
51 | (if command-form-p
52 | (let ((numeric (not (get object
53 | 'eshell-no-numeric-conversions)))
54 | (fname-args (get object 'eshell-filename-arguments)))
55 | (when (or numeric fname-args)
56 | (while args
57 | (let ((arg (car args)))
58 | (cond
59 | ((and numeric (stringp arg) (> (length arg) 0)
60 | (text-property-any 0 (length arg)
61 | 'number t arg))
62 | ;; If any of the arguments are flagged as
63 | ;; numbers waiting for conversion, convert
64 | ;; them now.
65 | (setcar args (string-to-number arg)))
66 | ((and fname-args (stringp arg)
67 | (string-equal arg "~"))
68 | ;; If any of the arguments match "~",
69 | ;; prepend "./" to treat it as a regular
70 | ;; file name.
71 | (setcar args (concat "./" arg)))))
72 | (setq args (cdr args))))
73 | (setq eshell-last-command-name
74 | (concat "#"))
75 | (eshell-apply* #'eshell-print-maybe-n
76 | #'eshell-error-maybe-n
77 | object eshell-last-arguments))
78 | (setq eshell-last-command-name "#")
79 | (eshell-eval* #'eshell-print-maybe-n
80 | #'eshell-error-maybe-n
81 | object))))
82 | (eshell-close-handles
83 | ;; If `eshell-lisp-form-nil-is-failure' is non-nil, Lisp forms
84 | ;; that succeeded but have a nil result should have an exit
85 | ;; status of 2.
86 | (when (and eshell-lisp-form-nil-is-failure
87 | (not command-form-p)
88 | (= eshell-last-command-status 0)
89 | (not result))
90 | 2)
91 | (list 'quote result))
92 | (and (eshell-function-target-p result)
93 | result))))
94 |
95 | (cl-defstruct (eshell-function-target
96 | (:include eshell-generic-target)
97 | (:constructor nil)
98 | (:constructor eshell-function-target-create
99 | (output-function &optional close-function)))
100 | "An Eshell target that calls an OUTPUT-FUNCTION."
101 | output-function close-function)
102 |
103 | (cl-defmethod eshell-get-target ((raw-target eshell-function-target) &optional _mode)
104 | "Convert a function RAW-TARGET into a valid output target.
105 | This just returns RAW-TARGET."
106 | raw-target)
--------------------------------------------------------------------------------
/lisp/eshell-ext-HEAD.el:
--------------------------------------------------------------------------------
1 | (defun eshell-exec-lisp (printer errprint func-or-form args form-p)
2 | "Execute a Lisp FUNC-OR-FORM, maybe passing ARGS.
3 | PRINTER and ERRPRINT are functions to use for printing regular
4 | messages and errors, respectively. FORM-P should be non-nil if
5 | FUNC-OR-FORM represent a Lisp form; ARGS will be ignored in that
6 | case."
7 | (eshell-condition-case err
8 | (let ((result
9 | (save-current-buffer
10 | (if form-p
11 | (eval func-or-form)
12 | (apply func-or-form args)))))
13 | ;; As a special case, a Lisp function or form may evaluate to an
14 | ;; `eshell-function-target', which represents a virtual output
15 | ;; device. In that case, any output piped to the lisp command
16 | ;; will be fed to that function. This makes it possible to use
17 | ;; Lisp commands on the right-hand side of a pipeline.
18 | (if (and result (not (eshell-function-target-p result)))
19 | (funcall printer result))
20 | result)
21 | (eshell-pipe-broken
22 | ;; If FUNC-OR-FORM tried and failed to write some output to a
23 | ;; process, it will raise an `eshell-pipe-broken' signal (this is
24 | ;; analogous to SIGPIPE on POSIX systems). In this case, set the
25 | ;; command status to some non-zero value to indicate an error; to
26 | ;; match GNU/Linux, we use 141, which the numeric value of
27 | ;; SIGPIPE on GNU/Linux (13) with the high bit (2^7) set.
28 | (when (memq eshell-in-pipeline-p '(nil last))
29 | (eshell-set-exit-info 141))
30 | nil)
31 | (error
32 | (when (memq eshell-in-pipeline-p '(nil last))
33 | (eshell-set-exit-info 1))
34 | (let ((msg (error-message-string err)))
35 | (unless form-p
36 | (let ((prog-name (string-trim-left (symbol-name func-or-form)
37 | "eshell/")))
38 | (if (eq (car err) 'wrong-number-of-arguments)
39 | (setq msg (format "%s usage: %s" prog-name
40 | (elisp-get-fnsym-args-string func-or-form)))
41 | (setq msg (format "%s: %s" prog-name msg)))))
42 | (funcall errprint msg))
43 | nil)))
44 |
45 | (defun eshell-lisp-command (object &optional args)
46 | "Insert Lisp OBJECT, using ARGS if a function."
47 | (unless eshell-allow-commands
48 | (signal 'eshell-commands-forbidden '(lisp)))
49 | (catch 'eshell-external ; deferred to an external command
50 | (when (memq eshell-in-pipeline-p '(nil last))
51 | (eshell-set-exit-info 0))
52 | (setq eshell-last-arguments args)
53 | (let* ((eshell-ensure-newline-p t)
54 | (command-form-p (functionp object))
55 | (result
56 | (if command-form-p
57 | (let ((numeric (not (get object
58 | 'eshell-no-numeric-conversions)))
59 | (fname-args (get object 'eshell-filename-arguments)))
60 | (when (or numeric fname-args)
61 | (while args
62 | (let ((arg (car args)))
63 | (cond
64 | ((and numeric (eshell--numeric-string-p arg))
65 | ;; If any of the arguments are flagged as
66 | ;; numbers waiting for conversion, convert
67 | ;; them now.
68 | (setcar args (string-to-number arg)))
69 | ((and fname-args (stringp arg)
70 | (string-equal arg "~"))
71 | ;; If any of the arguments match "~",
72 | ;; prepend "./" to treat it as a regular
73 | ;; file name.
74 | (setcar args (concat "./" arg)))))
75 | (setq args (cdr args))))
76 | (setq eshell-last-command-name
77 | (concat "#"))
78 | (eshell-apply* #'eshell-print-maybe-n
79 | #'eshell-error-maybe-n
80 | object eshell-last-arguments))
81 | (setq eshell-last-command-name "#")
82 | (eshell-eval* #'eshell-print-maybe-n
83 | #'eshell-error-maybe-n
84 | object))))
85 | (when (memq eshell-in-pipeline-p '(nil last))
86 | (eshell-set-exit-info
87 | ;; If `eshell-lisp-form-nil-is-failure' is non-nil, Lisp forms
88 | ;; that succeeded but have a nil result should have an exit
89 | ;; status of 2.
90 | (when (and eshell-lisp-form-nil-is-failure
91 | (not command-form-p)
92 | (= eshell-last-command-status 0)
93 | (not result))
94 | 2)
95 | result))
96 | (and (eshell-function-target-p result)
97 | result))))
98 |
99 | (cl-defmethod eshell-get-target ((raw-target eshell-function-target) &optional _mode)
100 | "Convert a function RAW-TARGET into a valid output target.
101 | This just returns RAW-TARGET."
102 | raw-target)
--------------------------------------------------------------------------------
/lisp/fo76-custom.el:
--------------------------------------------------------------------------------
1 | (require 'cl-lib)
2 |
3 | (defvar fo76-sort-order
4 | '("EVB76 - Meshes.ba2"
5 | "EVB76 - Textures.ba2"
6 | "CCO76 - Main.ba2"
7 | "Bombshell_Nuka-Girl - Main.ba2"
8 | ;; ----
9 | "InventOmaticPipboy-UO.ba2"
10 | "InventOmaticStash-UO.ba2"
11 | "HUDChallenges.ba2"
12 | "BuffsMeter.ba2"
13 | "CompatibleWeightIndicator.ba2"))
14 |
15 | (defvar fo76-ignore-list
16 | '("EVB76Nevernude - Meshes.ba2"
17 | "EVB76Nevernude - Textures.ba2"
18 |
19 | "SeventySix - 00UpdateMain.ba2"
20 | "SeventySix - 00UpdateTextures.ba2"
21 | "SeventySix - 00UpdateVoices.ba2"
22 | "SeventySix - 01UpdateMain.ba2"
23 | "SeventySix - 01UpdateStream.ba2"
24 | "SeventySix - 01UpdateTextures.ba2"
25 | "SeventySix - 01UpdateVoices.ba2"
26 | "SeventySix - 02UpdateMain.ba2"
27 | "SeventySix - 02UpdateStream.ba2"
28 | "SeventySix - 02UpdateTextures.ba2"
29 | "SeventySix - 02UpdateVoices.ba2"
30 | "SeventySix - Animations.ba2"
31 | "SeventySix - EnlightenExteriors01.ba2"
32 | "SeventySix - EnlightenExteriors02.ba2"
33 | "SeventySix - EnlightenExteriors03.ba2"
34 | "SeventySix - EnlightenInteriors01.ba2"
35 | "SeventySix - EnlightenInteriors02.ba2"
36 | "SeventySix - GeneratedMeshes01.ba2"
37 | "SeventySix - GeneratedMeshes02.ba2"
38 | "SeventySix - GeneratedTextures01.ba2"
39 | "SeventySix - GeneratedTextures02.ba2"
40 | "SeventySix - Interface.ba2"
41 | "SeventySix - Interface_en.ba2"
42 | "SeventySix - Interface_ja.ba2"
43 | "SeventySix - Interface_ko.ba2"
44 | "SeventySix - Interface_ru.ba2"
45 | "SeventySix - Interface_zhhans.ba2"
46 | "SeventySix - Interface_zhhant.ba2"
47 | "SeventySix - Localization.ba2"
48 | "SeventySix - Materials.ba2"
49 | "SeventySix - Meshes.ba2"
50 | "SeventySix - MeshesExtra.ba2"
51 | "SeventySix - MiscClient.ba2"
52 | "SeventySix - Shaders.ba2"
53 | "SeventySix - Sounds01.ba2"
54 | "SeventySix - Sounds02.ba2"
55 | "SeventySix - Startup.ba2"
56 | "SeventySix - StaticMeshes.ba2"
57 | "SeventySix - Textures01.ba2"
58 | "SeventySix - Textures02.ba2"
59 | "SeventySix - Textures03.ba2"
60 | "SeventySix - Textures04.ba2"
61 | "SeventySix - Textures05.ba2"
62 | "SeventySix - Textures06.ba2"
63 | "SeventySix - Textures07.ba2"
64 | "SeventySix - Textures08.ba2"
65 | "SeventySix - Textures09.ba2"
66 | "SeventySix - Textures10.ba2"
67 | "SeventySix - Voices.ba2"
68 | "SeventySix - WorkshopIcons.ba2"))
69 |
70 | (defun fo76-archive-files (dir)
71 | (let (result)
72 | (dolist (entry (directory-files dir))
73 | (unless (member entry '("." ".."))
74 | (let ((path (expand-file-name entry dir)))
75 | (if (string-match "\\.ba2\\'" path)
76 | (setq result
77 | (cons (file-name-nondirectory path)
78 | result))
79 | (if (file-directory-p path)
80 | (setq result
81 | (nconc result
82 | (fo76-archive-files path))))))))
83 | result))
84 |
85 | (defun fo76-compare-archives (x y)
86 | (let ((x-pos (cl-position x fo76-sort-order :test #'string=))
87 | (y-pos (cl-position y fo76-sort-order :test #'string=)))
88 | (if x-pos
89 | (if y-pos
90 | (< x-pos y-pos)
91 | nil)
92 | (if y-pos
93 | t
94 | (string< x y)))))
95 |
96 | (defun fo76-sort-archives (archives)
97 | (cl-stable-sort archives #'fo76-compare-archives))
98 |
99 | (defun fo76-sort-custom-ini ()
100 | (interactive)
101 | (with-current-buffer
102 | (find-file "C:\\Users\\jwieg\\OneDrive\\Documents\\My Games\\Fallout 76\\Fallout76Custom.ini")
103 | (goto-char (point-min))
104 | (search-forward "sResourceArchive2List=")
105 | (delete-region (match-end 0) (point-max))
106 | (insert
107 | (mapconcat
108 | #'identity
109 | (fo76-sort-archives
110 | (cl-delete-if
111 | #'(lambda (x) (cl-find x fo76-ignore-list :test #'string=))
112 | (fo76-archive-files "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Fallout76\\Data")))
113 | ","))))
114 |
--------------------------------------------------------------------------------
/lisp/gptel-proof.el:
--------------------------------------------------------------------------------
1 | ;;
2 | ;; A module to help with proofreading thanks to gptel
3 | ;;
4 |
5 | (require 'gptel)
6 | (require 'gptel-ollama)
7 | (require 'uuidgen)
8 |
9 | (defvar gptel-proof-gentle-prompt
10 | (concat "Please fix spelling, punctuation and grammar in the follow text. "
11 | "Where possible, keep the word choice and tone unchanged. "
12 | "Output only the corrected text. "
13 | "The outputed text should use a line length line breaks "
14 | "that are similar to the input text. Visually, the old "
15 | "and new text should look similar. They should also have "
16 | "as few whitespace changes as possible. The new and old text "
17 | "will be run through the unix command diff, so only "
18 | "critical changes should be visible."))
19 |
20 | (defvar gptel-proof-aggressive-prompt
21 | (concat "Please fix spelling, punctuation and grammar in the follow text. "
22 | "Where possible, rewrite the text to use active voice and to use fewer words."
23 | "Use a tone that's appropriate to publish in a social media post, so that it's casual "
24 | "but still something that my Mom would understand. "
25 | "The outputed text should use a line length line breaks "
26 | "that are similar to the input text. Visually, the old "
27 | "and new text should look similar. They should also have "
28 | "as few whitespace changes as possible. The new and old text "
29 | "will be run through the unix command diff, so only "
30 | "critical changes should be visible."))
31 |
32 | (defun gptel-proof-apply-fix (buffer marker correction)
33 | "Apply the changes chatgpt has suggested."
34 | (with-current-buffer buffer
35 | (goto-char (point-min))
36 | (when (re-search-forward marker nil t)
37 | (let* ((end (point))
38 | (start (- end (length marker))))
39 | (delete-region start end)
40 | (insert correction)))))
41 |
42 | (defun gptel-proof (start end &optional aggressive)
43 | "Proofread either the region using AI."
44 | (interactive "r\nP")
45 | (when (not (use-region-p))
46 | (error "No region selected"))
47 | (let* ((marker (format "{proof:%s}" (with-temp-buffer
48 | (uuidgen nil)
49 | (upcase (buffer-string)))))
50 | (input (buffer-substring start end))
51 | (prompt-style (if aggressive "aggressive" "gentle"))
52 | (start-conflict "<<<<<<< Original\n")
53 | (sep-conflict "=======\n")
54 | (end-conflict (format ">>>>>>> Proofread (%s)\n" prompt-style))
55 | (gptel-model 'gemma2:27b)
56 | (gptel-backend
57 | (gptel-make-ollama "Ollama"
58 | :host "localhost:11434"
59 | :protocol "http"
60 | :stream t
61 | :request-params '(:options (:num_ctx 32768))
62 | :models
63 | '((gemma2:27b
64 | :description "Google Gemma 2 is a high-performing and efficient model"
65 | :capabilities (media)
66 | :mime-types ("image/jpeg" "image/png" "text/plain"))))))
67 | (save-excursion
68 | (goto-char start)
69 | (insert start-conflict)
70 | (goto-char (+ end (length start-conflict)))
71 | (insert (concat sep-conflict marker "\n" end-conflict)))
72 | (gptel-request input
73 | :callback (lambda (response info)
74 | (if response
75 | (gptel-proof-apply-fix (plist-get info :buffer)
76 | (plist-get info :context)
77 | response)
78 | (error "Proofread error: %s" (plist-get info :status))))
79 | :context marker
80 | :system (if aggressive
81 | gptel-proof-aggressive-prompt
82 | gptel-proof-gentle-prompt))))
83 |
84 | (provide 'gptel-proof)
85 |
--------------------------------------------------------------------------------
/lisp/gptel-temp.el:
--------------------------------------------------------------------------------
1 | (require 'url-http)
2 |
3 | (defun my-current-temperature (place)
4 | (interactive "sLocation: ")
5 | (with-current-buffer
6 | (url-retrieve-synchronously
7 | (url-encode-url
8 | (format
9 | "http://api.weatherapi.com/v1/current.json?key=%s&q=%s&aqi=yes"
10 | (lookup-password "api.weatherapi.com" "jwiegley@gmail.com" 80)
11 | place)))
12 | (goto-char url-http-end-of-headers)
13 | (let ((json (json-parse-buffer :object-type 'alist)))
14 | (kill-buffer (current-buffer))
15 | (alist-get 'temp_f (alist-get 'current json)))))
16 |
17 | (defun my-gptel-rag-with-current-temperature (messages)
18 | (let ((last-user (gptel-rag-last-user-message messages)))
19 | (when (string-match "temperature in \\(.+?\\)\\?" last-user)
20 | (gptel-rag-add-system-message
21 | messages
22 | (let ((place (match-string 1 last-user)))
23 | (format "The current temperature in %s is %s"
24 | place (my-current-temperature place)))))))
25 |
26 | (provide 'gptel-temp)
27 |
--------------------------------------------------------------------------------
/lisp/gptel-tools.el:
--------------------------------------------------------------------------------
1 | (gptel-make-tool
2 | :function (lambda (x y)
3 | (format "The value of x and y multiplied is: %s" (* x y)))
4 | :name "multiply_numbers"
5 | :description "Multiply two numbers together"
6 | :args (list '(:name "x"
7 | :type "integer"
8 | :description "The first number to be multiplied")
9 | '(:name "y"
10 | :type "integer"
11 | :description "The second number to be multiplied"))
12 | :category "math"
13 | :confirm t)
14 |
15 | (gptel-make-tool
16 | :function (lambda (path filename content)
17 | (let ((full-path (expand-file-name filename path)))
18 | (with-temp-buffer
19 | (insert content)
20 | (write-file full-path))
21 | (format "Created file %s in %s" filename path)))
22 | :name "create_file"
23 | :description "Create a new file with the specified content"
24 | :args (list '(:name "path"
25 | :type "string"
26 | :description "The directory where to create the file")
27 | '(:name "filename"
28 | :type "string"
29 | :description "The name of the file to create")
30 | '(:name "content"
31 | :type "string"
32 | :description "The content to write to the file"))
33 | :category "filesystem")
34 |
35 | (provide 'gptel-tools)
36 |
--------------------------------------------------------------------------------
/lisp/haskell-yas.el:
--------------------------------------------------------------------------------
1 | ;;; haskell-yas.el --- Customization support for Luke Hoersten's yasnippets
2 |
3 | ;; Copyright (C) 2013 John Wiegley, Luke Hoersten
4 |
5 | ;; Author: John Wiegley
6 | ;; Luke Hoersten
7 | ;; Keywords: faces files Haskell
8 |
9 | ;; This file is not part of GNU Emacs.
10 |
11 | ;; This file is free software; you can redistribute it and/or modify
12 | ;; it under the terms of the GNU General Public License as published by
13 | ;; the Free Software Foundation; either version 3, or (at your option)
14 | ;; any later version.
15 |
16 | ;; This file is distributed in the hope that it will be useful,
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | ;; GNU General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with this program. If not, see .
23 |
24 | ;;; Commentary:
25 |
26 | ;; Provides customization variables for Luke Hoersten's yasnippet collection
27 | ;; to depend on.
28 |
29 | ;;; Code:
30 |
31 | (defgroup haskell-yas nil
32 | "Customizations for Luke Hoersten's yasnippet collection for haskell-mode."
33 | :group 'haskell
34 | :prefix "haskell-yas-")
35 |
36 | (defcustom haskell-yas-ghc-language-pragmas
37 | (split-string (shell-command-to-string "ghc --supported-extensions"))
38 | "List of language pragmas supported by the installed version of GHC."
39 | :group 'haskell-yas
40 | :type '(repeat string))
41 |
42 | (defcustom haskell-yas-completing-function 'ido-completing-read
43 | "Function to use for completing among alternatives."
44 | :group 'haskell-yas
45 | :type 'function)
46 |
47 | ;;;###autoload
48 | (defun haskell-yas-complete (&rest args)
49 | (apply haskell-yas-completing-function args))
50 |
51 | ;; Provide ourselves:
52 |
53 | (provide 'haskell-yas)
54 |
55 | ;;; haskell-yas.el ends here
56 |
--------------------------------------------------------------------------------
/lisp/howard.el:
--------------------------------------------------------------------------------
1 | ;;; These functions are from:
2 | ;;;
3 | ;;; https://howardism.org/Technical/Emacs/capturing-content.html
4 |
5 | (defun ha/org-capture-clip-snippet (f)
6 | "Given a file, F, this captures the currently selected text
7 | within an Org EXAMPLE block and a backlink to the file."
8 | (with-current-buffer (find-buffer-visiting f)
9 | (ha/org-capture-fileref-snippet f "EXAMPLE" "" nil)))
10 |
11 | (defun ha/org-capture-code-snippet (f)
12 | "Given a file, F, this captures the currently selected text
13 | within an Org SRC block with a language based on the current mode
14 | and a backlink to the function and the file."
15 | (with-current-buffer (find-buffer-visiting f)
16 | (let ((org-src-mode (replace-regexp-in-string "-mode" "" (format "%s" major-mode)))
17 | (func-name (which-function)))
18 | (ha/org-capture-fileref-snippet f "SRC" org-src-mode func-name))))
19 |
20 | (defun ha/org-capture-fileref-snippet (f type headers func-name)
21 | (let* ((code-snippet
22 | (buffer-substring-no-properties (mark) (- (point) 1)))
23 | (file-name (buffer-file-name))
24 | (file-base (file-name-nondirectory file-name))
25 | (line-number (line-number-at-pos (region-beginning)))
26 | (initial-txt (if (null func-name)
27 | (format "From [[file:%s::%s][%s]]:"
28 | file-name line-number file-base)
29 | (format "From ~%s~ (in [[file:%s::%s][%s]]):"
30 | func-name file-name line-number
31 | file-base))))
32 | (format "
33 | %s
34 |
35 | #+BEGIN_%s %s
36 | %s
37 | #+END_%s" initial-txt type headers code-snippet type)))
38 |
39 | (provide 'howard)
40 |
--------------------------------------------------------------------------------
/lisp/html.el:
--------------------------------------------------------------------------------
1 | (defun render-html ()
2 | (interactive)
3 | (shr-render-region (point-min) (point-max)))
4 |
5 | (defun clean-html ()
6 | (interactive)
7 | (whitespace-cleanup)
8 | (goto-char (point-max))
9 | (when (re-search-backward "^\\* HTML.+\n" nil t)
10 | (delete-blank-lines)
11 | (forward-line 1)
12 | (delete-region (point-min) (point))))
13 |
--------------------------------------------------------------------------------
/lisp/llm.el:
--------------------------------------------------------------------------------
1 | (require 'cl-lib)
2 | (require 'esh-io)
3 | (require 'esh-cmd)
4 |
5 | (defalias 'eshell-with-copied-handles 'eshell-copy-handles)
6 |
7 | (defun eshell/wc ()
8 | (eshell-with-copied-handles
9 | (let ((buf (get-buffer-create " *eshell/wc*")))
10 | (eshell-function-target-create
11 | `(lambda (input)
12 | (with-current-buffer ,buf
13 | (insert input)))
14 | `(lambda (_status)
15 | (let ((eshell-current-handles ,eshell-current-handles))
16 | (eshell-print
17 | (format "%s\n" (with-current-buffer ,buf (point-max)))))
18 | (kill-buffer ,buf))))))
19 |
20 |
--------------------------------------------------------------------------------
/lisp/loeb.el:
--------------------------------------------------------------------------------
1 | ;;; loeb.el --- Loeb function in Emacs Lisp -*- lexical-binding: t; -*-
2 |
3 | ;; Copyright © 2025 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; URL: https://github.com/jwiegley/dot-emacs
7 | ;; Keywords: function
8 |
9 | ;; This file is NOT part of GNU Emacs.
10 |
11 | ;; This program is free software; you can redistribute it and/or modify
12 | ;; it under the terms of the GNU General Public License as published by
13 | ;; the Free Software Foundation; either version 3, or (at your option)
14 | ;; any later version.
15 | ;;
16 | ;; This program is distributed in the hope that it will be useful,
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | ;; GNU General Public License for more details.
20 | ;;
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 | ;; Boston, MA 02110-1301, USA.
25 |
26 | ;;; Commentary:
27 | ;;
28 | ;; This library provides the loeb function, for sequences (lists and vectors),
29 | ;; alists and plists.
30 | ;;
31 | ;; See https://github.com/quchen/articles/blob/master/loeb-moeb.md for more
32 | ;; details and motivation.
33 |
34 | (require 'seq)
35 | (require 'thunk)
36 |
37 | (defun loeb-seq* (fs)
38 | "The loeb function, implemented in Emacs Lisp.
39 | This version does not force all values before returning.
40 | See `loeb-seq' for more information."
41 | (letrec ((go (seq-map (lambda (f) (thunk-delay (funcall f go))) fs)))
42 | go))
43 |
44 | (defun loeb-seq (fs)
45 | "The loeb function, implemented in Emacs Lisp.
46 | Basically, you take a sequence of functions from a sequence to a
47 | value, and calculate a sequence of values by passing the
48 | \"final\" sequence to every one of those functions. But it's a
49 | fixed point, so as long as it forms a DAG, the references all
50 | work out.
51 |
52 | Example:
53 | (loeb-seq (list (lambda (xs) (length xs))
54 | (lambda (xs) (+ (loeb-resolve (nth 0 xs)) (length xs)))))
55 | ==> (2 4)"
56 | (seq-map #'thunk-force (loeb-seq* fs)))
57 |
58 | (defun loeb-alist* (fs)
59 | "The loeb function, specialized to alists. See `loeb'.
60 | This version does not force all values before returning.
61 | See `loeb-alist' for more information."
62 | (letrec ((go (seq-map
63 | (lambda (cell)
64 | (cons (car cell)
65 | (thunk-delay (funcall (cdr cell) go))))
66 | fs)))
67 | go))
68 |
69 | (defun loeb-alist (fs)
70 | "The loeb function, specialized to alists. See `loeb'.
71 | Example:
72 | (loeb-alist '((foo . (lambda (alist)
73 | (loeb-resolve (alist-get 'bar alist))))
74 | (bar . (lambda (alist) 2))))
75 | ==> ((foo . 2)
76 | (bar . 2))"
77 | (seq-map (lambda (cell)
78 | (cons (car cell)
79 | (thunk-force (cdr cell))))
80 | (loeb-alist* fs)))
81 |
82 | (defun loeb-plist-map! (fn plist)
83 | "Map FN over PLIST, modifying it in-place and returning it.
84 | FN must take two arguments: the key and the value."
85 | (let ((plist-index plist))
86 | (while plist-index
87 | (let ((key (pop plist-index)))
88 | (setf (car plist-index) (funcall fn key (car plist-index))
89 | plist-index (cdr plist-index)))))
90 | plist)
91 |
92 | (defun loeb-plist* (fs)
93 | "The loeb function, specialized to plists. See `loeb'.
94 | This version does not force all values before returning.
95 | See `loeb-plist' for more information."
96 | (letrec ((go (loeb-plist-map!
97 | (lambda (_key value)
98 | (thunk-delay (funcall value go)))
99 | fs)))
100 | go))
101 |
102 | (defun loeb-plist (fs)
103 | "The loeb function, specialized to plists. See `loeb'.
104 | Example:
105 | (loeb-plist '(:foo (lambda (plist)
106 | (loeb-resolve (plist-get plist :bar)))
107 | :bar (lambda (plist) 2)))
108 | ==> (:foo 2 :bar 2)"
109 | (loeb-plist-map! (lambda (_key value) (thunk-force value))
110 | (loeb-plist* fs)))
111 |
112 | (defalias 'loeb-resolve 'thunk-force)
113 |
114 | (defsubst loeb-get (key alist)
115 | "Version of `alist-get' to be used with `loeb' and friends."
116 | (loeb-resolve (alist-get key alist)))
117 |
118 | (defun loeb-alist-overlays (&rest overlays)
119 | "Resolve all of the given alist OVERLAYS.
120 | Each overlay in OVERLAYS has the following general type:
121 |
122 | [(SYMBOL × (FINAL-ALIST → PARENT-ALIST → VALUE))]
123 |
124 | The function used for the \"value\" within each overlay receives
125 | two alists: the \"final\" closure after all overlays are
126 | performed, and the state of the closure just prior to that
127 | overlay.
128 |
129 | Note: this scheme implements a similar logic to what is found in
130 | nixpkgs. Here is a semi-realistic example:
131 |
132 | (loeb-alist-overlays
133 | '((foo . (lambda (final _parent)
134 | (1+ (loeb-get 'bar final))))
135 | (bar . (lambda (_final _parent)
136 | 123)))
137 | '((bar . (lambda (final parent)
138 | (+ 100 (loeb-get 'bar parent)))))
139 | '((foo . (lambda (final parent)
140 | (+ 100 (loeb-get 'foo parent))))
141 | (baz . (lambda (final parent)
142 | (+ 100 (loeb-get 'foo final))))))
143 | ==>
144 | ((baz . 424)
145 | (bar . 223)
146 | (foo . 324))
147 |
148 | Unfortunately, because Emacs Lisp does not have efficient
149 | immutable data structures, each generation of the alist between
150 | overlays must be copied \"in the spine\", which wastes as many
151 | cons cells as there are keys in each generation, plus the thunk
152 | closure created for each value of that generation."
153 | (loeb-alist
154 | (seq-reduce
155 | #'(lambda (acc overlay)
156 | ;; `acc' must be copied eagerly here, because the loop below is likely
157 | ;; to modify it in place. The loebed version, however, can wait until
158 | ;; it is first needed by `loeb-get'.
159 | (let* ((parent (copy-alist acc))
160 | (loebed (thunk-delay (loeb-alist* parent))))
161 | (dolist (entry overlay)
162 | (setf (alist-get (car entry) acc)
163 | #'(lambda (final)
164 | (funcall (cdr entry) final (thunk-force loebed)))))
165 | acc))
166 | overlays
167 | nil)))
168 |
169 | (provide 'loeb)
170 |
--------------------------------------------------------------------------------
/lisp/lzw.el:
--------------------------------------------------------------------------------
1 | ;;; lzw --- LZW compression algorithm in Emacs Lisp
2 |
3 | ;; Copyright (C) 2011-2012 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 6 Aug 2011
7 | ;; Version: 1.0
8 | ;; Keywords: compression data lzw
9 | ;; X-URL: https://github.com/jwiegley/dot-emacs
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; This code has not been optimized, and I welcome any improvements.
29 | ;; As it is, the resulting conversion of a large Lisp form to a
30 | ;; base64-encoded string, using `lzw-compress-data', achieves a
31 | ;; compression ratio near 50% over just turning the data into a string
32 | ;; with `prin1-to-string'.
33 |
34 | (defgroup lzw nil
35 | "LZW compression algorithm in Emacs Lisp"
36 | :group 'emacs)
37 |
38 | ;;; Code:
39 |
40 | (eval-when-compile
41 | (require 'cl))
42 |
43 | (defun lzw-compress-string (uncompressed)
44 | "Compress a string to a list of output symbols."
45 | ;; Build the dictionary.
46 | (let* ((dict-size 256)
47 | (dictionary
48 | (let ((dict (make-hash-table :size dict-size :test 'equal)))
49 | (dotimes (i dict-size)
50 | (puthash (char-to-string i) (char-to-string i) dict))
51 | dict)))
52 | (with-temp-buffer
53 | (let ((w ""))
54 | (dolist (c (string-to-list uncompressed))
55 | (let ((wc (concat w (char-to-string c))))
56 | (if (gethash wc dictionary)
57 | (setq w wc)
58 | (insert (gethash w dictionary))
59 | ;; Add wc to the dictionary.
60 | (puthash wc (char-to-string dict-size) dictionary)
61 | (setq dict-size (1+ dict-size)
62 | w (char-to-string c)))))
63 | ;; Output the code for w.
64 | (if w
65 | (insert (gethash w dictionary))))
66 | (buffer-string))))
67 |
68 | (defun lzw-decompress-string (compressed)
69 | "Decompress a list of output ks to a string."
70 | ;; Build the dictionary.
71 | (let* ((dict-size 256)
72 | (dictionary
73 | (let ((dict (make-hash-table :size dict-size :test 'equal)))
74 | (dotimes (i dict-size)
75 | (puthash (char-to-string i) (char-to-string i) dict))
76 | dict)))
77 | (with-temp-buffer
78 | (let* ((compr-list (string-to-list compressed))
79 | (w (char-to-string (pop compr-list))))
80 | (insert w)
81 | (dolist (k compr-list)
82 | (let ((entry
83 | (or (gethash (char-to-string k) dictionary)
84 | (if (= k dict-size)
85 | (concat w (char-to-string (aref w 0)))
86 | (error "Bad compressed k: %s" k)))))
87 | (insert entry)
88 |
89 | ;; Add w+entry[0] to the dictionary.
90 | (puthash (char-to-string dict-size)
91 | (concat w (char-to-string (aref entry 0)))
92 | dictionary)
93 | (setq dict-size (1+ dict-size)
94 | w entry))))
95 | (buffer-string))))
96 |
97 | (defun lzw-compress-data (data)
98 | (base64-encode-string
99 | (string-as-unibyte
100 | (lzw-compress-string
101 | (prin1-to-string data)))))
102 |
103 | (defun lzw-decompress-data (str)
104 | (read
105 | (lzw-decompress-string
106 | (string-as-multibyte
107 | (base64-decode-string str)))))
108 |
109 | (provide 'lzw)
110 |
111 | ;;; lzw.el ends here
112 |
--------------------------------------------------------------------------------
/lisp/main.el:
--------------------------------------------------------------------------------
1 | :;exec emacs -batch -l "$0" -f main "$@"
2 |
3 | (defun main ()
4 | (princ "Hello, world!\n"))
5 |
6 | ;;; main.el ends here
7 |
--------------------------------------------------------------------------------
/lisp/merlin.el:
--------------------------------------------------------------------------------
1 | (defun merlin-record-times ()
2 | (interactive)
3 | (require 'rx)
4 | (let* ((text (buffer-substring-no-properties (line-beginning-position)
5 | (line-end-position)))
6 | (regex
7 | (rx (and string-start (0+ space)
8 | (group (and (= 2 num) ?/ (= 2 num) ?/ (= 2 num)
9 | space (= 2 num) ?: (= 2 num) space
10 | (in "AP") ?M)) (1+ space)
11 | (group (and (= 2 num) ?/ (= 2 num) ?/ (= 2 num)
12 | space (= 2 num) ?: (= 2 num) space
13 | (in "AP") ?M)) (1+ space)
14 | (? (and (group ?*) (1+ space)))
15 | (group (1+ (or digit (in ".hms"))))
16 | (1+ space) (group (1+ nonl)) string-end))))
17 | (if (string-match regex text)
18 | (let ((start (match-string 1 text))
19 | (end (match-string 2 text))
20 | (cleared (match-string 3 text))
21 | (duration (match-string 4 text)) commodity
22 | (account (match-string 5 text)))
23 | (when (string-match "\\([0-9.]+\\)\\([mhs]\\)" duration)
24 | (setq commodity (match-string 2 duration)
25 | duration (match-string 1 duration))
26 | (cond ((string= commodity "h")
27 | (setq commodity "hours"))
28 | ((string= commodity "m")
29 | (setq commodity "minutes"))
30 | ((string= commodity "s")
31 | (setq commodity "seconds"))))
32 | (if (string-match "\\([0-9.][0-9.a-z]+\\)" account)
33 | (setq account (match-string 1 account)))
34 | (do-applescript
35 | (format "
36 | tell application \"Merlin\"
37 | activate
38 |
39 | set act to 0
40 |
41 | set listActivity to every activity of first document
42 | repeat with oneActivity in listActivity
43 | if subtitle of oneActivity is \"%s\" then
44 | set act to oneActivity
45 | exit repeat
46 | end if
47 | end repeat
48 |
49 | if act is 0 then
50 | set myselection to selected object of main window of first document as list
51 |
52 | if (count of myselection) is 0 then
53 | display dialog \"Please select activity to set time for\" buttons {\"OK\"}
54 | else
55 | set act to beginning of myselection
56 | end if
57 | end if
58 |
59 | if act is 0 or (class of act is project) or (is milestone of act is true) then
60 | display dialog \"Cannot locate activity for %s\" buttons {\"OK\"}
61 | else
62 | tell act
63 | if ((class is not project) and (is milestone is not true)) then
64 | set actual start date to (date \"%s\")
65 | if %s then
66 | set actual end date to (date \"%s\")
67 | delete last actuals reporting date
68 |
69 | set given remaining work to {amount:0, unit:hours, floating:false, ¬
70 | relative error:0}
71 | else
72 | delete actual end date
73 | set last actuals reporting date to (date \"%s\")
74 | end if
75 | set given actual work to {amount:%s, unit:%s, floating:false, ¬
76 | relative error:0}
77 | end if
78 | end tell
79 | end if
80 | end tell" account account start (if cleared "true" "false")
81 | end end duration commodity))))))
82 |
--------------------------------------------------------------------------------
/lisp/onnx-example.el:
--------------------------------------------------------------------------------
1 | ;; We assume the library is available in your load-path and you have downloaded
2 | ;; the necessary model onnx file
3 | (require 'onnx)
4 | (require 'onnx-ml-utils)
5 | (setq model (onnx-load "model_O2.onnx"))
6 |
7 | (require 'tokenizers)
8 |
9 | ;; Model loading here happens via automatic http downloads
10 | ;; `encoding' is a list of token-ids, token-type-ids, and attention-mask
11 | (setq encoding (let ((tk (tokenizers-from-pretrained "sentence-transformers/all-MiniLM-L6-v2")))
12 | (tokenizers-enable-padding tk 0 "[PAD]")
13 | (tokenizers-encode-batch tk ["This is an example sentence" "Each sentence is converted"] t)))
14 |
15 | (let ((output (onnx-run model `(("input_ids" . ,(nth 0 encoding))
16 | ("token_type_ids" . ,(nth 1 encoding))
17 | ("attention_mask" . ,(nth 2 encoding)))
18 | '("last_hidden_state"))))
19 | (setq output (onnx-ml-utils-nmean-pool output (nth 2 encoding)))
20 | (onnx-ml-utils-nl2-normalize output)
21 | output) ;; Shape N x D
22 |
--------------------------------------------------------------------------------
/lisp/org-agenda-overlay.el:
--------------------------------------------------------------------------------
1 | ;;; org-agenda-overlay --- Code to overlay entries in org-agenda
2 |
3 | ;; Copyright (C) 2024 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 7 Oct 2024
7 | ;; Version: 1.0
8 | ;; Keywords: org capture task todo context
9 | ;; X-URL: https://github.com/jwiegley/dot-emacs
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | (require 'cl-lib)
29 | (require 'org)
30 |
31 | (defun org-agenda-overlay-filetags ()
32 | (save-excursion
33 | (goto-char (point-min))
34 | (ignore-errors
35 | (when (re-search-forward "^#\\+filetags: :\\(.+\\):" 4096 t)
36 | (split-string (match-string-no-properties 1) ":")))))
37 |
38 | (defun compare-lists-up-to-shortest (list1 list2)
39 | "Compare LIST1 and LIST2 up to the length of the shortest list."
40 | (not (cl-some 'null (cl-mapcar 'equal list1 list2))))
41 |
42 | (defcustom org-agenda-overlay-by-filetag nil
43 | "Mapping of tags to overlay properties.
44 | Example: ((\"Work\" face (:background \"#fdfdeb\")))"
45 | :group 'org-agenda-overlay
46 | :type '(repeat
47 | (cons string sexp)))
48 |
49 | (defcustom org-agenda-overlay-by-olp nil
50 | "Mapping of outline paths (given as lists) to overlay properties.
51 | Example: (((\"Work\") face (:background \"#fdfdeb\")))"
52 | :group 'org-agenda-overlay
53 | :type '(repeat
54 | (cons (repeat string) sexp)))
55 |
56 | (defcustom org-agenda-overlay-use-properties nil
57 | "If non-nil, also use OVERLAY entry and file properties.
58 | This is nil by default because it can be very slow."
59 | :group 'org-agenda-overlay
60 | :type 'boolean)
61 |
62 | (defun org-agenda-overlay-get-global-property (name)
63 | (save-excursion
64 | (goto-char (point-min))
65 | (and (re-search-forward (concat "#\\+PROPERTY: " name " \\(.*\\)") nil t)
66 | (match-string 1))))
67 |
68 | (defun org-agenda-overlay-add (&optional line)
69 | "Add overlays found in OVERLAY properties to agenda items.
70 | Note that habitual items are excluded, as they already
71 | extensively use text properties to draw the habits graph.
72 |
73 | For example, for work tasks I like to use a subtle, yellow
74 | background color; for tasks involving other people, green; and
75 | for tasks concerning only myself, blue. This way I know at a
76 | glance how different responsibilities are divided for any given
77 | day.
78 |
79 | To achieve this, I have the following in my todo file:
80 |
81 | * Work
82 | :PROPERTIES:
83 | :CATEGORY: Work
84 | :OVERLAY: (face (:background \"#fdfdeb\"))
85 | :END:
86 | ** TODO Task
87 | * Family
88 | :PROPERTIES:
89 | :CATEGORY: Personal
90 | :OVERLAY: (face (:background \"#e8f9e8\"))
91 | :END:
92 | ** TODO Task
93 | * Personal
94 | :PROPERTIES:
95 | :CATEGORY: Personal
96 | :OVERLAY: (face (:background \"#e8eff9\"))
97 | :END:
98 | ** TODO Task
99 |
100 | To use this function, add it to `org-agenda-finalize-hook':
101 |
102 | (add-hook 'org-agenda-finalize-hook 'org-agenda-overlay-add)"
103 | (let ((inhibit-read-only t)
104 | (buffer-invisibility-spec '(org-link)))
105 | (save-excursion
106 | (goto-char (if line (line-beginning-position) (point-min)))
107 | (while (not (eobp))
108 | (let ((org-marker (get-text-property (point) 'org-marker))
109 | (type-prop (get-text-property (point) 'type)))
110 | (when (and org-marker
111 | type-prop
112 | (string-match "\\(sched\\|dead\\|todo\\)" type-prop)
113 | (null (overlays-at (point)))
114 | (not (get-text-property (point) 'org-habit-p)))
115 | (let ((overlays
116 | (or (and org-agenda-overlay-use-properties
117 | (org-entry-get org-marker "OVERLAY" t))
118 | (with-current-buffer (marker-buffer org-marker)
119 | (or (and org-agenda-overlay-use-properties
120 | (org-agenda-overlay-get-global-property "OVERLAY"))
121 | (catch 'found
122 | (dolist (mapping org-agenda-overlay-by-filetag)
123 | (dolist (tag (org-agenda-overlay-filetags))
124 | (when (string= (car mapping) tag)
125 | (throw 'found (cdr mapping))))))
126 | (catch 'found
127 | (dolist (mapping org-agenda-overlay-by-olp)
128 | (when (compare-lists-up-to-shortest
129 | (car mapping)
130 | (save-excursion
131 | (goto-char org-marker)
132 | (org-get-outline-path)))
133 | (throw 'found (cdr mapping))))))))))
134 | (when overlays
135 | (goto-char (line-end-position))
136 | (let ((rest (- (window-width) (current-column))))
137 | (if (> rest 0)
138 | (insert (make-string rest ? ))))
139 | (let ((ol (make-overlay (line-beginning-position)
140 | (line-end-position)))
141 | (proplist (if (stringp overlays)
142 | (read overlays)
143 | overlays)))
144 | (while proplist
145 | (overlay-put ol (car proplist) (cadr proplist))
146 | (setq proplist (cddr proplist))))))))
147 | (forward-line)))))
148 |
149 | (provide 'org-agenda-overlay)
150 |
151 | ;;; org-agenda-overlay.el ends here
152 |
--------------------------------------------------------------------------------
/lisp/org-agenda-random.el:
--------------------------------------------------------------------------------
1 | ;;; -*- lexical-binding: t; -*-
2 |
3 | ;;; This code is by Aaron Harris from:
4 | ;;; https://emacs.stackexchange.com/questions/24270/org-mode-pick-random-task-from-custom-agenda-view
5 | ;;;
6 | ;;; Example use:
7 | ;;;
8 | ;;; '("d" "daily start"
9 | ;;; ((agenda ""
10 | ;;; ((org-agenda-span 'day)
11 | ;;; (org-agenda-skip-function
12 | ;;; '(org-agenda-skip-entry-if 'notregexp ":start:"))
13 | ;;; (org-agenda-max-entries 5)
14 | ;;; (org-agenda-cmp-user-defined (org-compare-randomly))
15 | ;;; (org-compare-random-refresh t)
16 | ;;; (org-agenda-sorting-strategy '(user-defined-up))))))
17 |
18 | (defun org-compare--get-marker (entry)
19 | "Return the marker for ENTRY.
20 |
21 | This marker points to the location of the headline referenced by
22 | ENTRY."
23 | (get-text-property 1 'org-marker entry))
24 |
25 | (defvar org-compare-random-refresh nil
26 | "Whether `org-compare-randomly' should refresh its keys.
27 |
28 | See the docs for `org-compare-randomly' for more information.")
29 |
30 | (defun org-compare-randomly--update-sort-key (entry table generator)
31 | "Return sort key for ENTRY in TABLE, generating it if necessary.
32 | For internal use by `org-compare-randomly-by'."
33 | (let* ((marker (org-compare--get-marker entry))
34 | (hash-key `(,(marker-buffer marker) . ,(marker-position marker))))
35 | (or (gethash hash-key table)
36 | (puthash hash-key (funcall generator entry) table))))
37 |
38 | (defun org-compare-randomly-by (generator)
39 | "Return a random comparator using GENERATOR.
40 |
41 | The comparator returned is like `org-compare-randomly', except
42 | the distribution of random keys is controlled by GENERATOR and
43 | may thus be non-uniform.
44 |
45 | The function GENERATOR is called with a single argument, an
46 | agenda entry, when that entry lacks a sort key. It should return
47 | a number, which is then used for all comparisons until the key
48 | list is cleared; see `org-compare-randomly' for more details on
49 | this.
50 |
51 | Subsequent calls to `org-compare-randomly-by' produce comparators
52 | with independent sets of sort keys."
53 | (let ((table (make-hash-table :test #'equal)))
54 | (lambda (x y)
55 | (when org-compare-random-refresh
56 | (clrhash table)
57 | (setq org-compare-random-refresh nil))
58 | (let ((x-val (org-compare-randomly--update-sort-key x table generator))
59 | (y-val (org-compare-randomly--update-sort-key y table generator)))
60 | (cond
61 | ((= x-val y-val) nil)
62 | ((< x-val y-val) -1)
63 | ((> x-val y-val) +1))))))
64 |
65 | (defun org-compare-randomly ()
66 | "Return a comparator implementing a random shuffle.
67 |
68 | When given distinct agenda entries X and Y, the resulting
69 | comparator has an equal chance of returning +1 and -1 (and a
70 | miniscule chance of returning nil). Subsequent calls will produce
71 | results consistent with a total ordering.
72 |
73 | To accomplish this, a hash table of randomly-generated sort keys
74 | is maintained. This table will persist until the comparator is
75 | called when the variable `org-compare-random-refresh' is non-nil.
76 | This means that setting this variable as part of a custom agenda
77 | command using this comparator as `org-agenda-cmp-user-defined'
78 | will cause the sort order to change whenever the agenda is
79 | refreshed; otherwise, it will persist until Emacs is restarted.
80 |
81 | Note that if you don't want the sort order to change on refresh,
82 | you need to be careful that the comparator is created when the
83 | custom agenda command is defined, not when it's called, e.g.
84 |
85 | (add-to-list
86 | 'org-agenda-custom-commands
87 | `(\"y\" \"Example Agenda\"
88 | ((todo
89 | \"\"
90 | ((org-agenda-cmp-user-defined ',(org-compare-randomly))
91 | (org-agenda-sorting-strategy '(user-defined-up)))))))
92 |
93 | \(Notice the use of backquote.)
94 |
95 | Comparators resulting from different calls to this function have
96 | independent key tables."
97 | (org-compare-randomly-by (lambda (_) (random))))
98 |
99 | (provide 'org-agenda-random)
100 |
--------------------------------------------------------------------------------
/lisp/org-balance.el:
--------------------------------------------------------------------------------
1 | ;; `org-todo-score' algorithm:
2 | ;;
3 | ;; todo metadata:
4 | ;;
5 | ;; - Number of days since creation
6 | ;; - Number of other tasks in the same project/category
7 | ;; - Number of tasks in that project/category closed since creation date
8 | ;; - Date when last task in that project/category was closed
9 | ;; - Priority of the task
10 | ;; - Number of tasks with same priority or higher in the project/category
11 | ;; - Number of tasks closed in that project/category in the last quarter
12 |
13 | (defun org-todo-score (&optional ignore)
14 | "Compute the score of an Org-mode task.
15 | Age gradually decreases the value given to a task. After 28
16 | days, its score is zero.
17 | Effort should act as a multiplier on the value."
18 | 1)
19 |
20 | (defvar org-categories-pending-hashmap nil)
21 | (defvar org-categories-completed-hashmap nil)
22 |
23 | (defun org-compute-category-totals ()
24 | (interactive)
25 | (setq org-categories-pending-hashmap (make-hash-table :test 'equal)
26 | org-categories-completed-hashmap (make-hash-table :test 'equal))
27 | (dolist (file '("todo.txt" "archive.txt"))
28 | (with-current-buffer
29 | (find-file-noselect (expand-file-name file "~/doc"))
30 | (save-excursion
31 | (goto-char (point-min))
32 | (while (not (eobp))
33 | (outline-next-heading)
34 | (let* ((state (org-get-todo-state))
35 | (category
36 | (or (org-entry-get (point) "ARCHIVE_CATEGORY" t)
37 | (org-entry-get (point) "CATEGORY" t)))
38 | (hashmap
39 | (cond
40 | ((string= state "TODO") org-categories-pending-hashmap)
41 | ((string= state "DONE") org-categories-completed-hashmap)))
42 | (value (and hashmap (gethash category hashmap 0))))
43 | (if hashmap
44 | (puthash category (+ value (org-todo-score)) hashmap))))))))
45 |
46 | (defun org-category-total (category)
47 | ;; A category's final score is the sum of all open tasks (which raises the
48 | ;; value), subtracted by the sum of all closed tasks. Thus, a category with
49 | ;; a higher score deserves more attention (it has been neglected or has not
50 | ;; seen much activity), while a category with a low score deserves less.
51 | ;;
52 | ;; Note that this score is affected by several heuristics. See
53 | ;; `org-todo-score'.
54 | (unless org-categories-pending-hashmap
55 | (org-compute-category-totals))
56 | (- (gethash category org-categories-pending-hashmap 0)
57 | (gethash category org-categories-completed-hashmap 0)))
58 |
59 | (defun org-cmp-category-totals (a b)
60 | (let ((cat-a (get-text-property 1 'org-category a))
61 | (cat-b (get-text-property 1 'org-category b)))
62 | (if (> (org-category-total cat-a)
63 | (org-category-total cat-b))
64 | 1
65 | -1)))
66 |
67 | ;; (setq org-agenda-cmp-user-defined 'org-cmp-category-totals)
68 |
--------------------------------------------------------------------------------
/lisp/org-color.el:
--------------------------------------------------------------------------------
1 | (require 's)
2 | (require 'term/tty-colors)
3 |
4 | (defun color-fg-comp (&optional arg)
5 | "Completion function for color links."
6 | (let ((color-fg-data
7 | (prog2
8 | (save-selected-window
9 | (list-colors-display))
10 | (with-current-buffer (get-buffer "*Colors*")
11 | (mapcar (lambda (line)
12 | (append (list line)
13 | (s-split " " line t)))
14 | (s-split "\n" (buffer-string))))
15 | (kill-buffer "*Colors*"))))
16 | (format "fg:%s"
17 | (s-trim (cadr (assoc (completing-read "Color: " color-fg-data)
18 | color-fg-data))))))
19 |
20 | (defun color-fg-link-face (path)
21 | "Face function for color links."
22 | `(:foreground ,path))
23 |
24 | (defun color-fg-link-export (path description backend)
25 | "Export function for color links."
26 | (cond
27 | ((eq backend 'html)
28 | (let ((rgb (assoc (downcase path) color-name-rgb-alist))
29 | r g b)
30 | (setq r (* 255 (/ (nth 1 rgb) 65535.0))
31 | g (* 255 (/ (nth 2 rgb) 65535.0))
32 | b (* 255 (/ (nth 3 rgb) 65535.0)))
33 | (format "%s"
34 | (truncate r) (truncate g) (truncate b)
35 | (or description path))))))
36 |
37 | (org-link-set-parameters "fg"
38 | :face 'color-fg-link-face
39 | :complete 'color-fg-comp
40 | :export 'color-fg-link-export)
41 |
42 | (defun color-bg-comp (&optional arg)
43 | "Completion function for color links."
44 | (let ((color-bg-data
45 | (prog2
46 | (save-selected-window
47 | (list-colors-display))
48 | (with-current-buffer (get-buffer "*Colors*")
49 | (mapcar (lambda (line)
50 | (append (list line)
51 | (s-split " " line t)))
52 | (s-split "\n" (buffer-string))))
53 | (kill-buffer "*Colors*"))))
54 | (format "fg:%s"
55 | (s-trim (cadr (assoc (completing-read "Color: " color-bg-data)
56 | color-bg-data))))))
57 |
58 | (defun color-bg-link-face (path)
59 | "Face function for color links."
60 | `(:background ,path))
61 |
62 | (defun color-bg-link-export (path description backend)
63 | "Export function for color links."
64 | (cond
65 | ((eq backend 'html)
66 | (let ((rgb (assoc (downcase path) color-name-rgb-alist))
67 | r g b)
68 | (setq r (* 255 (/ (nth 1 rgb) 65535.0))
69 | g (* 255 (/ (nth 2 rgb) 65535.0))
70 | b (* 255 (/ (nth 3 rgb) 65535.0)))
71 | (format "%s"
72 | (truncate r) (truncate g) (truncate b)
73 | (or description path))))))
74 |
75 | (org-link-set-parameters "bg"
76 | :face 'color-bg-link-face
77 | :complete 'color-bg-comp
78 | :export 'color-bg-link-export)
79 |
80 | (provide 'org-color)
81 |
--------------------------------------------------------------------------------
/lisp/org-constants.el:
--------------------------------------------------------------------------------
1 | ;;; This file should be loaded before Org-mode, or any other modules that
2 | ;;; loads Org.
3 |
4 | (defconst org-constants-directory "~/org/")
5 |
6 | (defconst org-constants-journelly-path
7 | "~/Library/Mobile Documents/iCloud~com~xenodium~Journelly/Documents/Journelly.org")
8 |
9 | (defconst org-constants-flat-habits-path
10 | "~/Library/Mobile Documents/com~apple~CloudDocs/Flat Habits/MyHabits.org")
11 |
12 | (defconst org-constants-plain-org-path
13 | "~/Library/Mobile Documents/com~apple~CloudDocs/Plain Org/Mobile.org")
14 |
15 | (defsubst org-constants-file (path)
16 | (expand-file-name path org-constants-directory))
17 |
18 | (defalias 'org-file 'org-constants-file)
19 |
20 | (defconst org-constants-todo-path (org-file "todo.org"))
21 |
22 | (defconst org-constants-work-todo-path (org-file "kadena/kadena.org"))
23 |
24 | (defconst org-constants-work-asana-path (org-file "kadena/asana.org"))
25 |
26 | (defconst org-constants-kadena-team-file "kadena/team/202409042228-team.org"
27 | "File containing names of team members and links to their files.")
28 |
29 | (defconst org-constants-assembly-path (org-file "assembly/assembly.org"))
30 |
31 | (defconst org-constants-open-source-path (org-file "OSS.org"))
32 |
33 | (defconst org-constants-people-path (org-file "people.org"))
34 |
35 | (defconst org-constants-agenda-base-files
36 | (list org-constants-todo-path
37 | org-constants-work-todo-path
38 | (org-file "assembly/assembly.org")
39 | (org-file "quantum-trades/quantum-trades.org")
40 | org-constants-open-source-path))
41 |
42 | (defconst org-constants-protected-filenames-list
43 | (list (file-name-nondirectory org-constants-todo-path)
44 | "kadena/kadena.org"
45 | "assembly/assembly.org"
46 | "quantum-trades/quantum-trades.org"
47 | (file-name-nondirectory org-constants-open-source-path)
48 | (file-name-nondirectory org-constants-people-path)
49 | (file-name-nondirectory org-constants-journelly-path)
50 | (file-name-nondirectory org-constants-flat-habits-path)
51 | (file-name-nondirectory org-constants-plain-org-path)))
52 |
53 | (defconst org-constants-protected-basenames-list
54 | (mapcar #'file-name-nondirectory org-constants-protected-filenames-list))
55 |
56 | (provide 'org-constants)
57 |
--------------------------------------------------------------------------------
/lisp/org-debbugs.el:
--------------------------------------------------------------------------------
1 | ;;; org-debbugs.el - Support for links to debbugs messages by their UUID
2 |
3 | ;; version 1.1, by John Wiegley
4 |
5 | (require 'org)
6 |
7 | (org-add-link-type "x-debbugs-gnu" 'org-debbugs-open)
8 |
9 | (defun org-debbugs-open (record-location)
10 | "Visit the debbugs-gnu bug with the given id."
11 | (message "(gnus-read-ephemeral-emacs-bug-group %d)" (string-to-number record-location))
12 | (gnus-read-ephemeral-emacs-bug-group (string-to-number record-location)))
13 |
14 | (defun org-get-debbugs-link (&optional given-name)
15 | (interactive)
16 | (let* ((status (debbugs-gnu-current-status))
17 | (id (cdr (assq 'id status)))
18 | (subject (cdr (assq 'subject status))))
19 | (cons (format "x-debbugs-gnu:%d" id)
20 | (or given-name subject))))
21 |
22 | (defun org-insert-debbugs-link ()
23 | (interactive)
24 | (let (name)
25 | (when (region-active-p)
26 | (setq name (buffer-substring-no-properties (region-beginning)
27 | (region-end)))
28 | (delete-region (region-beginning) (region-end)))
29 | (let ((link-data (org-get-debbugs-link name)))
30 | (insert (org-make-link-string (car link-data) (cdr link-data))))))
31 |
32 | (defun org-debbugs-store-link ()
33 | "Store a link to an debbugs-gnu bug by its id."
34 | (let ((link-data (org-get-debbugs-link)))
35 | (org-store-link-props
36 | :type "x-debbugs-gnu"
37 | :link (cons (car link-data) (car link-data))
38 | :description (cdr link-data))))
39 |
40 | (provide 'org-debbugs)
41 |
42 | ;;; org-debbugs.el ends here
43 |
--------------------------------------------------------------------------------
/lisp/org-devonthink.el:
--------------------------------------------------------------------------------
1 | ;;; org-devonthink.el - Support for links to DEVONthink messages by their UUID
2 |
3 | ;; version 1.1, by John Wiegley
4 |
5 | (require 'org)
6 | (require 'org-roam)
7 |
8 | (org-add-link-type "x-devonthink-item" 'org-devonthink-open)
9 |
10 | (defsubst org-devonthink-open (record-location)
11 | "Visit the DEVONthink message with the given Message-ID."
12 | (browse-url (concat "x-devonthink-item://" record-location)))
13 |
14 | (defsubst org-devonthink-message-open (message-id)
15 | (org-devonthink-open
16 | (concat "%3C" (url-encode-url (substring message-id 2)) "%3E"))
17 |
18 | ;; (browse-url
19 | ;; (concat "https://app.fastmail.com/mail/search:msgid%3A"
20 | ;; (url-encode-url (substring message-id 2))
21 | ;; "/?u=d30140a0"))
22 |
23 | ;; (require 'gnus-util)
24 | ;; (if (get-buffer "*Group*")
25 | ;; (gnus-goto-article
26 | ;; (gnus-string-remove-all-properties (substring message-id 2)))
27 | ;; (error "Gnus is not running"))
28 | )
29 |
30 | (when nil
31 | (org-devonthink-message-open "//ledger/ledger/pull/2419/review/2876546626@github.com"))
32 |
33 | (defun org-devonthink-get-link (&optional given-name)
34 | (interactive)
35 | (let ((name (or given-name
36 | (do-applescript (format "
37 | tell application \"DEVONthink 3\"
38 | try
39 | get name of content record
40 | on error errMsg
41 | get name of current group
42 | end try
43 | end tell"))))
44 | (location (do-applescript (format "
45 | tell application \"DEVONthink 3\"
46 | try
47 | get uuid of content record
48 | on error errMsg
49 | get uuid of current group
50 | end try
51 | end tell"))))
52 | (org-make-link-string
53 | (concat "x-devonthink-item://" (org-remove-double-quotes location))
54 | (org-remove-double-quotes name))))
55 |
56 | (defun org-devonthink-set-link ()
57 | "Set a property for the current headline."
58 | (interactive)
59 | (org-set-property (if (org-entry-get (point-marker) "URL")
60 | "URL"
61 | "URL2")
62 | (org-devonthink-get-link))
63 | (org-toggle-tag "LINK" 'on))
64 |
65 | (defun org-devonthink-insert-link ()
66 | (interactive)
67 | (let (name)
68 | (when (region-active-p)
69 | (setq name (buffer-substring-no-properties (region-beginning)
70 | (region-end)))
71 | (delete-region (region-beginning) (region-end)))
72 | (insert (org-devonthink-get-link name))))
73 |
74 | (defun org-devonthink-store-link ()
75 | "Store a link to an DEVONthink e-mail message by Message-ID."
76 | (let ((link-name
77 | (with-temp-buffer
78 | (clipboard-yank)
79 | (buffer-string))))
80 | (org-store-link-props
81 | :type "x-devonthink-item"
82 | :link (cons (concat "x-devonthink-item://" link-name)
83 | (concat "x-devonthink-item://" link-name))
84 | :description (file-name-nondirectory link-name))))
85 |
86 | (defun org-devonthink-uuid-to-path (uuid)
87 | "Visit the message with the given MESSAGE-ID.
88 | This will use the command `open' with the message URL."
89 | (interactive)
90 | (when (and uuid
91 | (string-match "\\`\\(\\[*x-devonthink-item://\\)?\\([-A-Fa-z0-9]+\\)"
92 | uuid))
93 | (let ((base-uuid (match-string 2 uuid)))
94 | (read (do-applescript
95 | (format "tell application \"DEVONthink 3\"
96 | set searchResult to get record with uuid \"%s\"
97 | path of searchResult
98 | end tell" base-uuid))))))
99 |
100 | (provide 'org-devonthink)
101 |
102 | ;;; org-devonthink.el ends here
103 |
--------------------------------------------------------------------------------
/lisp/org-ql-ext.el:
--------------------------------------------------------------------------------
1 | (require 'org)
2 | (require 'org-ext)
3 | (require 'org-ql)
4 | (require 'org-ql-find)
5 |
6 | (org-ql-defpred keyword (&rest keywords)
7 | "Search for entries about any of NAMES."
8 | :body (cl-loop
9 | for kw in keywords
10 | thereis (member kw (split-string
11 | (or (org-entry-get (point) "KEYWORDS") "")))))
12 |
13 | (org-ql-defpred shown ()
14 | "Whether this entry is not marked as HIDE."
15 | :body (not (org-entry-get (point) "HIDE")))
16 |
17 | (org-ql-defpred about (&rest keywords)
18 | "Whether this entry is \"about\" the given keyword.
19 | This means checking if it's in the tags or CATEGORY."
20 | :body (cl-loop
21 | for kw in keywords
22 | thereis (or (member kw (org-get-tags (point)))
23 | (string= kw (org-get-category (point))))))
24 |
25 | (org-ql-defpred tasks-for (&rest who)
26 | "True if this task is assigned to, or related to, anyone in WHO."
27 | :body (and (apply #'org-ql--predicate-about who)
28 | (org-ql--predicate-todo)
29 | (org-ql--predicate-shown)))
30 |
31 | (org-ql-defpred refile-target ()
32 | "Return non-nil if entry is a refile target."
33 | :body (org-ext-refile-heading-p))
34 |
35 | (org-ql-defpred property-ts (property &key from to _on regexp _with-time args)
36 | "Match timestamps in property value."
37 | :normalizers ((`(,predicate-names ,property . ,rest)
38 | `(property-ts ,property
39 | ,@(org-ql--normalize-from-to-on
40 | `(:from ,from :to ,to)))))
41 | :body (when-let ((value (org-entry-get (point) property))
42 | (ts (ignore-errors
43 | (ts-parse-org value))))
44 | (cond ((not (or from to)) ts)
45 | ((and from to) (ts-in from to ts))
46 | (from (ts<= from ts))
47 | (to (ts<= ts to)))))
48 |
49 | (defvar org-ql-ext-heading-to-id (make-hash-table :test 'equal))
50 |
51 | (defun org-ql-ext-completions-at-point ()
52 | "Function to be used as `completion-at-point' in Org mode."
53 | (when (looking-back "@\\(\\(?:\\sw\\|\\s_\\|\\s-\\|\\s-:\\)+\\)" nil)
54 | (let* ((start (match-beginning 1))
55 | (end (point))
56 | (input (match-string-no-properties 1))
57 | (candidates
58 | (org-ql-select
59 | (org-agenda-files)
60 | (org-ql--query-string-to-sexp input)
61 | :action (lambda ()
62 | (let* ((heading (org-get-heading t))
63 | (id (org-id-get (point))))
64 | ;; Avoid having to look up the ID again since we
65 | ;; are visiting all the locations with org-ql
66 | ;; anyway
67 | (puthash heading id org-ql-ext-heading-to-id)
68 | heading))))
69 | (exit-function
70 | (lambda (heading status)
71 | (when (eq status 'finished)
72 | ;; The +1 removes the @ symbol
73 | (delete-char (- (+ (length heading) 1)))
74 | (insert
75 | (format "[[id:%s][%s]]"
76 | (gethash heading org-ql-ext-heading-to-id)
77 | heading))))))
78 | (list start end candidates :exit-function exit-function))))
79 |
80 | (defun org-ql-ext-completion-hook ()
81 | "Configure org-mode for completion at point for org-agenda headlines."
82 | (add-to-list 'completion-at-point-functions
83 | 'org-ql-ext-completions-at-point))
84 |
85 | (defun org-ql-ext-find-refile-targets ()
86 | (interactive)
87 | (let ((query-prefix "refile-target: ")
88 | current-prefix-arg)
89 | (cond
90 | ((eq major-mode 'dired-mode)
91 | (let ((org-ql-search-directories-files-recursive t))
92 | (org-ql-find (org-ql-search-directories-files
93 | :directories (list org-directory))
94 | :query-prefix query-prefix)))
95 | ((eq major-mode 'org-mode)
96 | (org-ql-find (org-ql-find--buffers)))
97 | (t
98 | (org-ql-find (org-agenda-files)
99 | :query-prefix query-prefix)))))
100 |
101 | (provide 'org-ql-ext)
102 |
--------------------------------------------------------------------------------
/lisp/paredit-ext.el:
--------------------------------------------------------------------------------
1 | ;;; paredit-ext --- Extra functions for paredit
2 |
3 | ;; Copyright (C) 2012 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 03 Jul 2012
7 | ;; Version: 1.0
8 | ;; Keywords: paredit lisp
9 | ;; X-URL: https://github.com/jwiegley/dot-emacs
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; These commands are ones that I use very often.
29 |
30 | (require 'paredit)
31 |
32 | (defgroup paredit-ext nil
33 | "Extra functions for paredit"
34 | :group 'paredit)
35 |
36 | (defun mark-containing-sexp ()
37 | (interactive)
38 | (paredit-backward-up)
39 | (mark-sexp))
40 |
41 | (defun paredit-barf-all-the-way-backward ()
42 | (interactive)
43 | (paredit-split-sexp)
44 | (paredit-backward-down)
45 | (paredit-splice-sexp))
46 |
47 | (defun paredit-barf-all-the-way-forward ()
48 | (interactive)
49 | (paredit-split-sexp)
50 | (paredit-forward-down)
51 | (paredit-splice-sexp)
52 | (if (eolp) (delete-horizontal-space)))
53 |
54 | (defun paredit-slurp-all-the-way-backward ()
55 | (interactive)
56 | (catch 'done
57 | (while (not (bobp))
58 | (save-excursion
59 | (paredit-backward-up)
60 | (if (eq (char-before) ?\()
61 | (throw 'done t)))
62 | (paredit-backward-slurp-sexp))))
63 |
64 | (defun paredit-slurp-all-the-way-forward ()
65 | (interactive)
66 | (catch 'done
67 | (while (not (eobp))
68 | (save-excursion
69 | (paredit-forward-up)
70 | (if (eq (char-after) ?\))
71 | (throw 'done t)))
72 | (paredit-forward-slurp-sexp))))
73 |
74 | (defun paredit--is-at-start-of-sexp ()
75 | (and (looking-at "(\\|\\[")
76 | (not (nth 3 (syntax-ppss))) ;; inside string
77 | (not (nth 4 (syntax-ppss))))) ;; inside comment
78 |
79 | (defun paredit-duplicate-closest-sexp ()
80 | (interactive)
81 | ;; skips to start of current sexp
82 | (while (not (paredit--is-at-start-of-sexp))
83 | (paredit-backward))
84 | (set-mark-command nil)
85 | ;; while we find sexps we move forward on the line
86 | (while (and (bounds-of-thing-at-point 'sexp)
87 | (<= (point) (car (bounds-of-thing-at-point 'sexp)))
88 | (not (= (point) (line-end-position))))
89 | (forward-sexp)
90 | (while (looking-at " ")
91 | (forward-char)))
92 | (kill-ring-save (mark) (point))
93 | ;; go to the next line and copy the sexprs we encountered
94 | (paredit-newline)
95 | (yank)
96 | (exchange-point-and-mark))
97 |
98 | (nconc paredit-commands
99 | '("Extreme Barfage & Slurpage"
100 | (("C-M-)")
101 | paredit-slurp-all-the-way-forward
102 | ("(foo (bar |baz) quux zot)"
103 | "(foo (bar |baz quux zot))")
104 | ("(a b ((c| d)) e f)"
105 | "(a b ((c| d)) e f)"))
106 | (("C-M-}")
107 | paredit-barf-all-the-way-forward
108 | ("(foo (bar |baz quux) zot)"
109 | "(foo (bar|) baz quux zot)"))
110 | (("C-M-(")
111 | paredit-slurp-all-the-way-backward
112 | ("(foo bar (baz| quux) zot)"
113 | "((foo bar baz| quux) zot)")
114 | ("(a b ((c| d)) e f)"
115 | "(a b ((c| d)) e f)"))
116 | (("C-M-{")
117 | paredit-barf-all-the-way-backward
118 | ("(foo (bar baz |quux) zot)"
119 | "(foo bar baz (|quux) zot)"))
120 | (("C-M->")
121 | paredit-duplicate-closest-sexp
122 | ("(foo | bar)"
123 | "(foo bar)(foo bar)"))))
124 |
125 | (paredit-define-keys)
126 | (paredit-annotate-mode-with-examples)
127 | (paredit-annotate-functions-with-examples)
128 |
129 | (provide 'paredit-ext)
130 |
131 | ;;; paredit-ext.el ends here
132 |
--------------------------------------------------------------------------------
/lisp/persian-johnw.el:
--------------------------------------------------------------------------------
1 | (require 'quail)
2 |
3 | (quail-define-package
4 | "farsi-transliterate-johnw" "Farsi" "ج" t
5 | "My intuitive transliteration keyboard layout for Persian/Farsi.
6 | " nil t t t t nil nil nil nil nil t)
7 |
8 | (quail-define-rules
9 | ;;;;;;;;;;; isiri-6219 Table 5 -- جدول ۵ - حروِفِ اصلیِ فارسی
10 | ("~" ?ء) ;; hamzeh
11 | ("A" ?آ) ;; U+0622 & ARABIC LETTER ALEF WITH MADDA ABOVE & الف با کلاه
12 | ("a" ?ا) ;; U+0627 & ARABIC LETTER ALEF & الف
13 | ("\\a" ?أ)
14 | ("b" ?ب) ;; U+0628 & ARABIC LETTER BEH &
15 | ("p" ?پ) ;; U+067e & ARABIC LETTER PEH &
16 | ("t" ?ت)
17 | ("tt" ?ت)
18 | ("c" ?ث)
19 | ("cc" ?ث)
20 | ("j" ?ج)
21 | ("ch" ?چ)
22 | ("h" ?ه)
23 | ("kh" ?خ)
24 | ("d" ?د)
25 | ("dh" ?ذ)
26 | ("r" ?ر)
27 | ("z" ?ز)
28 | ("zz" ?ز)
29 | ("zh" ?ژ)
30 | ("s" ?س)
31 | ("ss" ?س)
32 | ("sh" ?ش)
33 | ("-" ?ش)
34 | ("S" ?ص)
35 | ("D" ?ض)
36 | ("T" ?ط)
37 | ("TT" ?ط)
38 | ("Z" ?ظ)
39 | ("`" ?ع)
40 | ("Q" ?غ)
41 | ("f" ?ف)
42 | ("q" ?ق)
43 | ("gh" ?غ)
44 | ("k" ?ک)
45 | ("kk" ?ک)
46 | ("g" ?گ)
47 | ("gg" ?گ)
48 | ("l" ?ل)
49 | ("m" ?م)
50 | ("n" ?ن)
51 | ("v" ?و)
52 | ("u" ?و)
53 | ("V" ?ؤ)
54 | ("H" ?ح)
55 | ("y" ?ی)
56 | ("i" ?ی)
57 | ("I" ?ئ)
58 |
59 |
60 | ;;;;;;;;;;; isiri-6219 Table 6 -- جدول ۶ - حروِفِ عربی
61 | ("F" ?إ)
62 | ("D" ?\u0671) ;; (ucs-insert #x0671)ٱ named: حرفِ الفِ وصل
63 | ("K" ?ك) ;; Arabic kaf
64 | ("Th" ?ة) ;; ta marbuteh
65 | ("Y" ?ي)
66 | ("YY" ?ي)
67 | ("Yh" ?ى)
68 |
69 | ;;;;;;;;;;; isiri-6219 Table 4 -- جدول ۴ - ارقام و علائم ریاضی
70 | ("0" ?۰)
71 | ("1" ?۱)
72 | ("2" ?۲)
73 | ("3" ?۳)
74 | ("4" ?۴)
75 | ("5" ?۵)
76 | ("6" ?۶)
77 | ("7" ?۷)
78 | ("8" ?۸)
79 | ("9" ?۹)
80 |
81 | ("\\/" ?\u066B) ;; (ucs-insert #x066B)٫ named: ممیزِ فارسی
82 | ("\\," ?\u066C) ;; (ucs-insert #x066C)٬ named: جداکنندهی هزارهای فارسی
83 | ("%" ?\u066A) ;; (ucs-insert #x066A)٪ named: درصدِ فارسی
84 | ("+" ?\u002B) ;; (ucs-insert #x002B)+ named: علامتِ بهاضافه
85 | ("-" ?\u2212) ;; (ucs-insert #x2212)− named: علامتِ منها
86 | ("\\*" ?\u00D7) ;; (ucs-insert #x00D7)× named: علامتِ ضرب
87 | ("\\%" ?\u007F) ;; (ucs-insert #x00F7)÷ named: علامتِ تقسیم
88 | ("<" ?\u003C) ;; (ucs-insert #x003C)< named: علامتِ کوچکتر
89 | ("=" ?\u003D) ;; (ucs-insert #x003D)= named: علامتِ مساوی
90 | (">" ?\u003E) ;; (ucs-insert #x003E)> named: علامتِ بزرگتر
91 |
92 |
93 | ;;;;;;;;;;; isiri-6219 Table 2 -- جدول ۲ - علائم نقطه گذاریِ مشترک
94 | ;;; Space
95 | ("." ?.) ;;
96 | (":" ?\u003A) ;; (ucs-insert #x003A): named:
97 | ("!" ?\u0021) ;; (ucs-insert #x0021)! named:
98 | ("\\." ?\u2026) ;; (ucs-insert #x2026)… named:
99 | ("\\-" ?\u2010) ;; (ucs-insert #x2010)‐ named:
100 | ("-" ?\u002D) ;; (ucs-insert #x002D)- named:
101 | ("|" ?|)
102 | ;;("\\\\" ?\)
103 | ("//" ?/)
104 | ("*" ?\u002A) ;; (ucs-insert #x002A)* named:
105 | ("(" ?\u0028) ;; (ucs-insert #x0028)( named:
106 | (")" ?\u0029) ;; (ucs-insert #x0029)) named:
107 | ("[" ?\u005B) ;; (ucs-insert #x005B)[ named:
108 | ("[" ?\u005D) ;; (ucs-insert #x005D)] named:
109 | ("{" ?\u007B) ;; (ucs-insert #x007B){ named:
110 | ("}" ?\u007D) ;; (ucs-insert #x007D)} named:
111 | ("\\<" ?\u00AB) ;; (ucs-insert #x00AB)« named:
112 | ("\\>" ?\u00BB) ;; (ucs-insert #x00BB)» named:
113 |
114 |
115 | ;;;;;;;;;;; isiri-6219 Table 3 -- جدول ۳ - علائم نقطه گذاریِ فارسی
116 | ("," ?،) ;; farsi
117 | (";" ?؛) ;;
118 | ("?" ?؟) ;; alamat soal
119 | ("_" ?ـ) ;;
120 |
121 |
122 | ;;;;;;;;;;; isiri-6219 Table 1 -- جدول ۱ - نویسههای کنترلی
123 | ;; LF
124 | ;; CR
125 | ("" ?\u200C) ;; (ucs-insert #x200C) named: فاصلهی مجازی
126 | ("/" ?\u200C) ;;
127 | ("" ?\u200D) ;; (ucs-insert #x200D) named: اتصالِ مجازی
128 | ("J" ?\u200D) ;;
129 | ("" ?\u200E) ;; (ucs-insert #x200E) named: نشانهی چپبهراست
130 | ("" ?\u200F) ;; (ucs-insert #x200F) named: نشانهی راستبهچپ
131 | ("&ls;" ?\u2028) ;; (ucs-insert #x2028)
named: جداکنندهی سطرها
132 | ("&ps;" ?\u2028) ;; (ucs-insert #x2029)
named: جداکنندهی بندها
133 | ("&lre;" ?\u202A) ;; (ucs-insert #x202A) named: زیرمتنِ چپبهراست
134 | ("&rle;" ?\u202B) ;; (ucs-insert #x202B) named: زیرمتنِ راستبهچپ
135 | ("&pdf;" ?\u202C) ;; (ucs-insert #x202C) named: پایانِ زیرمتن
136 | ("&lro;" ?\u202D) ;; (ucs-insert #x202D) named: زیرمتنِ اکیداً چپبهراست
137 | ("&rlo;" ?\u202D) ;; (ucs-insert #x202E) named: زیرمتنِ اکیداً راستبهچپ
138 | ("&bom;" ?\uFEFF) ;; (ucs-insert #xFEFF) named: نشانهی ترتیبِ بایتها
139 |
140 |
141 | ;;;;;;;;;;; isiri-6219 Table 7 -- جدول ۷ - نشانههایِ فارسی
142 | ("'" ?َ) ;; zbar ;; زبر فارسى
143 | ("e" ?ِ) ;; zir زير فارسى
144 | ("o" ?ُ) ;; peesh ;; پيش فارسى -- ضمه
145 | ("E" ?ٍ) ;; eizan ;; دو زير فارسى -- تنوين جر
146 | ("#" ?ً) ;; دو زبر
147 | ("O" ?ٌ) ;; دو پيش فارسى -- تنوين رفع
148 | ("w" ?ّ) ;; tashdid ;; تشديد فارسى
149 | ("W" ?ْ) ;; ساکن فارسى
150 | ("U" ?\u0653) ;; (ucs-insert #x0653)ٓ named: مدِ فارسی
151 | ;;("`" ?ٔ) ;; همزه فارسى بالا
152 | ("C" ?\u0655) ;; (ucs-insert #x0655)ٕ named: همزه فارسى پایین
153 | ("$" ?\u0670) ;; (ucs-insert #x0670)ٰ named: الفِ مقصورهی فارسی
154 |
155 |
156 | ;;;;;;;;;;; isiri-6219 Table 8 - Forbidden Characters -- جدول ۸ - نویسههایِ ممنوع
157 | ;; ;; he ye (ucs-insert 1728) kills emacs-24.0.90
158 | ;; arabic digits 0-9
159 |
160 |
161 | ;;;;;;; Latin Extensions
162 | ("\\" ?\\) ;; خط اريب وارو
163 | ("\\\\" ?\\)
164 | ("\\~" ?~)
165 | ("\\@" ?@)
166 | ("\\#" ?#)
167 | ("\\$" ?\uFDFC) ;; (ucs-insert #xFDFC)﷼ named:
168 | ("\\^" ?^)
169 | ("\\1" ?1)
170 | ("\\2" ?2)
171 | ("\\3" ?3)
172 | ("\\4" ?4)
173 | ("\\5" ?5)
174 | ("\\6" ?6)
175 | ("\\7" ?7)
176 | ("\\8" ?8)
177 | ("\\9" ?9)
178 | ("\\0" ?0)
179 |
180 | )
181 |
182 | (provide 'persian-johnw)
183 |
--------------------------------------------------------------------------------
/lisp/prover.el:
--------------------------------------------------------------------------------
1 | (defcustom coq-use-Case t
2 | "Whether to use the Case hack for constructor alternatives."
3 | :type 'boolean
4 | :group 'coq-config)
5 |
6 | (defcustom coq-use-bullets t
7 | "Whether to use bullets for scoping constructor alternatives."
8 | :type 'boolean
9 | :group 'coq-config)
10 |
11 | (defun coq-insert-induction (name pos)
12 | "Given the name of a variable in scope, insert induction cases for it."
13 | (interactive "sInduction over term: ")
14 | (proof-shell-ready-prover)
15 | (let* ((leader
16 | (save-excursion
17 | (beginning-of-line)
18 | (let ((beg (point)))
19 | (skip-syntax-forward " ")
20 | (- (point) beg))))
21 | (thetype
22 | (ignore-errors
23 | (with-temp-buffer
24 | (insert (proof-shell-invisible-cmd-get-result
25 | (concat "Check " name ".")))
26 | (goto-char (point-max))
27 | (skip-syntax-backward " ")
28 | (delete-region (point) (point-max))
29 | (search-backward " : ")
30 | (delete-region (point-min) (match-end 0))
31 | (goto-char (point-min))
32 | (forward-word 1)
33 | (buffer-substring (point-min) (point)))))
34 | (indstr
35 | (ignore-errors
36 | (with-temp-buffer
37 | (insert (proof-shell-invisible-cmd-get-result
38 | (concat "Show Match " thetype ".")))
39 | (goto-char (point-min))
40 | (let (ctors)
41 | (while (re-search-forward "| \\(.+?\\) =>" nil t)
42 | (push (match-string 1) ctors))
43 | (goto-char (point-min))
44 | (re-search-forward "| \\S-+ ")
45 | (delete-region (point-min) (point))
46 | (insert "[")
47 | (while (re-search-forward "=>\\(.\\|\n\\)+?| \\S-+ " nil t)
48 | (replace-match "|"))
49 | (goto-char (point-max))
50 | (search-backward "=>" nil t)
51 | (delete-region (point) (point-max))
52 | (insert "].")
53 | (mapc #'(lambda (x)
54 | (insert ?\n (make-string leader ? ))
55 | (when coq-use-bullets
56 | (insert "- "))
57 | (when coq-use-Case
58 | (insert (format "Case \"%s = %s\"." name x))))
59 | (nreverse ctors))
60 | (buffer-string))))))
61 | indstr))
62 |
63 | (provide 'prover)
64 |
--------------------------------------------------------------------------------
/lisp/regex-tool/TODO:
--------------------------------------------------------------------------------
1 | REGEX-TOOL -*- mode: org; fill-column: 78 -*-
2 |
3 | #+STARTUP: overview
4 | #+ARCHIVE: TODO-OLD::
5 | #+SEQ_TODO: TODO(@) STARTED(@) WAITING(@) DELEGATED(@) | DONE(@) DEFERRED(@) CANCELLED(@) WONTFIX(@) WORKSFORME(@) INVALID(@) DUPLICATE(@) NOTE
6 | #+TAGS: FEATURE(f) DOCS(d) WEBSITE(w) BUILD(b) ATTACH(a)
7 | #+CATEGORY: rgx-tool
8 |
9 | * TODO [#B] Add regex-tool patch for Emacs 21 support
10 | (from e-mail [[message://47A86418.6000704@trueposition.com][regex-tool]]): Works okay in emacs 22, but I had to add this
11 | [attached] to backport to emacs 21.
12 | :PROPERTIES:
13 | :Submitter: Mitchell Perilstein
14 | :ID: 064CDAC0-D021-422C-BB16-F563CCF575A6
15 | :Attachments: remove-overlays.el
16 | :END:
17 | [2008-02-05 Tue]
18 | * TODO [#B] T. Kurt Bond suggested several changes to regex-tool :ATTACH:
19 | (from e-mail [[message://uabovlded.fsf@tkb.mpl.com][regex-tool.el patch]]): I've enclosed a patch that adds two
20 | things:
21 |
22 | 1. An *Elisp* buffer that shows a quoted version of the regex suitable for
23 | cutting and pasting into emacs lisp source. Unfortunately, I didn't take
24 | into account the perl backend, so it would need some tweaking.
25 |
26 | 2. Allows more than 9 matches to be displayed, so that
27 | \(1\)\(2\)\(3\)\(4\)\(5\)\(6\)\(7\)\(8\)\(9\)\(a\)\(b\)\(c\)\(d\)\(e\)\(f\)
28 | matched against
29 | 123456789abcdef
30 | shows all 15 individual matches in addition to the group 0 match.
31 | (Just look for the change to dotimes.)
32 | :PROPERTIES:
33 | :Submitter: T. Kurt Bond
34 | :ID: F7E77C16-2EB1-4447-A192-B1916DE45279
35 | :Attachments: bond.patch
36 | :END:
37 | [2007-11-30 Fri]
38 | * TODO [#B] Patch for / characters in a regular expression :ATTACH:
39 | I found a minor bug though: in perl mode it uses m// syntax, but slashes
40 | aren't escaped in elisp code, which makes the tool fail if I have '/' in
41 | regexp. This patch helped me [attached].
42 | :PROPERTIES:
43 | :Submitter: Marcin Bachry
44 | :ID: 597BF019-56C5-4C72-B13C-E8D8C930ADC5
45 | :Attachments: guard-slash.patch
46 | :END:
47 | [2008-03-27 Thu]
48 | * TODO [#B] Apply patch to regex-tool sent by Christian Stucchio :ATTACH:
49 | (from e-mail [[message://60424aeb0712270704q263ba990h7b5c7db9eaea058c@mail.gmail.com][regex-tool.el]]): So far, I've only found one thing I dislike:
50 | the fact that it opens a new frame. I prefer it to open in the current
51 | frame.
52 |
53 | I've attached a slightly modified version in which that behavior is
54 | customizable. If regex-tool-new-frame is t (the default), the current
55 | behavior is preserved. If nil, the current frame is used. Steal the code if
56 | you like it.
57 | :PROPERTIES:
58 | :Submitter: Christian Stucchio
59 | :ID: C37A5A8A-8EF2-4788-855A-961DA72C69E7
60 | :Attachments: reuse-frame.patch
61 | :END:
62 | [2007-12-27 Thu]
63 | * TODO [#B] Johan LindstrXm found a typo in regex-tool
64 | (from e-mail [[message://200801202048.BYP36673@imap.infopop.com][Regex Tool - wrong description?]]): This defun looks like it was
65 | copied from org-mode and not cleaned up properly :)
66 | :OUTPUT:
67 | (defgroup regex-tool nil
68 | "Outline-based notes management and organizer."
69 | :tag "Org"
70 | :group 'programming)
71 | :END:
72 | :PROPERTIES:
73 | :Submitter: Johan LindstrXm
74 | :ID: 107D4BC7-5949-4933-9D94-0E682C9748F0
75 | :END:
76 | [2008-01-20 Sun]
77 | * TODO [#A] Apply Johan LindstrXm's regex-tool patch :ATTACH:
78 | (from e-mail [[message://200801202043.BYP36639@imap.infopop.com][Regex Tool]]): I just recently started using your excellent Emacs
79 | Regex Tool. Very useful, so hats off for that!
80 |
81 | One thing I missed though was the ability of specifying Perl regex
82 | modifiers, such as /x etc. So I wrote a patch to change the Perl regex
83 | syntax from 'MY-REGEX' to '/MY-REGEX/MODIFIERS'
84 |
85 | (It is still aware of /g and multiple matches if needed)
86 |
87 | This patch would change the usage in an incompatible way from before, but
88 | OTOH this tool is supposedly not used programmatically anyway so that's
89 | probably not a big deal.
90 |
91 | If you think this sounds like a good idea, I'd be very happy for you to
92 | incorporate it with your package.
93 | :PROPERTIES:
94 | :Submitter: Johan LindstrXm
95 | :ID: 915929F6-4A97-43E0-861C-25B9B7FE9AF9
96 | :Attachments: regex-modifiers.patch
97 | :END:
98 | [2008-01-20 Sun]
99 |
--------------------------------------------------------------------------------
/lisp/ruhi.el:
--------------------------------------------------------------------------------
1 | (defun replicate (len str)
2 | (let (result)
3 | (dotimes (_i len)
4 | (setq result (concat result str)))
5 | result))
6 |
7 | (defun ruhi-convert-underscores ()
8 | (interactive)
9 | (if (re-search-forward "�+" nil t)
10 | (let ((len (length (match-string 0))))
11 | (replace-match (concat "[[fg:purple][" (replicate len "_") "]]")))))
12 |
13 | (defun ruhi-convert-quotations ()
14 | (interactive)
15 | (if (re-search-forward "\\(“.+?”\\)\\([0-9]+\\)" nil t)
16 | (replace-match (concat "#+begin_quote\n*" (match-string 1)
17 | "*[fn:u1r" (match-string 2)
18 | "]\n#+end_quote"))))
19 |
20 | (defun ruhi-convert-numbered-list ()
21 | (interactive)
22 | (if (re-search-forward "^\\([0-9]+\\)\\." nil t)
23 | (replace-match (concat (match-string 1)
24 | ". [@"
25 | (match-string 1)
26 | "]"))))
27 |
28 | (defun ruhi-convert-footnote-definitions ()
29 | (interactive)
30 | (if (re-search-forward "^\\([0-9]+\\)\\." nil t)
31 | (replace-match (concat "[fn:u2r" (match-string 1) "]"))))
32 |
33 | (provide 'ruhi)
34 |
--------------------------------------------------------------------------------
/lisp/sh-toggle.el:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwiegley/dot-emacs/5fde10831807587d3dc3476519884165096c00a1/lisp/sh-toggle.el
--------------------------------------------------------------------------------
/lisp/springboard/README.md:
--------------------------------------------------------------------------------
1 | How many times have you wanted to fire off a quick command, such as M-!, but
2 | the directory you want to run the command in isn't the same as the directory
3 | of the current buffer? In those situations, you want a quick way to change
4 | the default-directory *for only the next command*. That is what Springboard
5 | aims to solve.
6 |
7 | Bind it to a convenient key, like `Control-.`, and after you press it you'll
8 | see a handy Helm buffer showing the directories of all the files you've
9 | recently visited, plus the permanent directory list from
10 | `springboard-directories` -- a good place to list your active project
11 | directories.
12 |
13 | Type a few chars to narrow down to the directory of interest, then just type
14 | your command, like `M-!`, `C-x C-f`, or whatever custom bindings you may have
15 | to run PCVS, Magit, etc. The moment you type your command, Springboard
16 | disappears, and if your command needs minibuffer input, you'll now be in the
17 | minibuffer for that new command.
18 |
--------------------------------------------------------------------------------
/lisp/springboard/ido-springboard.el:
--------------------------------------------------------------------------------
1 | ;;; ido-springboard.el --- Temporarily change default-directory for one command
2 |
3 | ;; Copyright (C) 2012 John Wiegley
4 |
5 | ;; Author: John Wiegley
6 | ;; Created: 13 Jun 2012
7 | ;; Version: 1.0
8 | ;; Keywords: ido
9 | ;; X-URL: https://github.com/jwiegley/springboard
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; How many times have you wanted to fire off a quick command, such as M-!,
29 | ;; but the directory you want to run the command in isn't the same as the
30 | ;; directory of the current buffer? In those situations, you want a quick way
31 | ;; to change the default-directory *for only the next command*. That is what
32 | ;; Ido-Springboard aims to solve.
33 | ;;
34 | ;; It overrides command keys in ido-mode so that they use the
35 | ;; default-directory of the current viable completion, rather than the
36 | ;; default-directory of the buffer where you started the ido command.
37 |
38 | (require 'ido)
39 |
40 | (defgroup ido-springboard nil
41 | "Change default-directory for commands invoked at `ido-switch-buffer'."
42 | :group 'ido)
43 |
44 | (defcustom ido-springboard-ignored-commands
45 | '(self-insert-command
46 | delete-backward-char
47 | abort-recursive-edit
48 | exit-minibuffer
49 | switch-to-buffer
50 | backward-char
51 | forward-char
52 | kill-line
53 | move-beginning-of-line
54 | move-end-of-line
55 | backward-kill-word
56 | forward-kill-word)
57 | "Commands that will not be trapped by Ido-Springboard."
58 | :type '(repeat command)
59 | :group 'ido-springboard)
60 |
61 | (eval-when-compile
62 | (defvar ido-springboard-trapped nil))
63 |
64 | (defun ido-springboard-match-directory ()
65 | (let ((item (or (let ((buf (get-buffer (car ido-matches))))
66 | (and buf
67 | (with-current-buffer buf
68 | default-directory)))
69 | (and ido-use-virtual-buffers ido-virtual-buffers
70 | (cdr (assoc (car ido-matches)
71 | ido-virtual-buffers))))))
72 | (cond ((file-directory-p item)
73 | item)
74 | ((file-exists-p item)
75 | (file-name-directory item))
76 | (t
77 | nil))))
78 |
79 | (defun ido-springboard-add-trap ()
80 | (add-hook 'pre-command-hook 'ido-springboard-trap-command t t))
81 |
82 | (defun ido-springboard-remove-trap ()
83 | (remove-hook 'pre-command-hook 'ido-springboard-trap-command t))
84 |
85 | (defun ido-springboard-trap-command ()
86 | (unless ido-springboard-trapped
87 | (condition-case err
88 | (unless (or (memq this-command ido-springboard-ignored-commands)
89 | (string-match "\\`ido-" (symbol-name this-command)))
90 | (let ((dir (ido-springboard-match-directory)))
91 | (when dir
92 | ;; (message "Trapped command: %s" this-command)
93 | (loop for buf in (buffer-list)
94 | when (minibufferp buf)
95 | do (with-current-buffer buf
96 | (ido-springboard-remove-trap)))
97 | (setq ido-springboard-trapped t)
98 | (throw 'abort dir))))
99 | (error
100 | (message "Error occurred: %s" err)))))
101 |
102 | ;;;###autoload
103 | (defadvice ido-switch-buffer (around ido-springboard-ido-switch-buffer activate)
104 | "Adds ability to set `default-directory' for commands at ido minibuffer."
105 | (interactive)
106 | (add-hook 'minibuffer-setup-hook 'ido-springboard-add-trap)
107 | (add-hook 'minibuffer-exit-hook 'ido-springboard-remove-trap)
108 | (unwind-protect
109 | (let* (ido-springboard-trapped
110 | ido-springboard-already-trapped
111 | (default-directory (catch 'abort (ignore ad-do-it))))
112 | (if default-directory
113 | (call-interactively this-command)))
114 | (remove-hook 'minibuffer-setup-hook 'ido-springboard-add-trap)
115 | (remove-hook 'minibuffer-exit-hook 'ido-springboard-remove-trap)))
116 |
117 | (provide 'ido-springboard)
118 |
119 | ;;; ido-springboard.el ends here
120 |
--------------------------------------------------------------------------------
/lisp/vulpea-field.el:
--------------------------------------------------------------------------------
1 | (require 'vulpea)
2 |
3 | ;;;###autoload
4 | (defsubst vulpea-field-query (table-name note)
5 | (eval
6 | `(org-roam-db-query
7 | [:select [field] :from ,table-name
8 | :where (= note-id $s1)]
9 | (vulpea-note-id note))))
10 |
11 | ;;;###autoload
12 | (defun vulpea-field-setup (table-name predicate accessor processor)
13 | (vulpea-db-define-table
14 | ;; name
15 | table-name
16 | ;; version
17 | 1
18 | ;; schema
19 | '([(note-id :unique :primary-key)
20 | field]
21 | ;; useful to automatically cleanup your table whenever a note/node/file is removed
22 | (:foreign-key [note-id] :references nodes [id] :on-delete :cascade))
23 | ;; index
24 | '((field-id-index [note-id])))
25 |
26 | (add-hook 'vulpea-db-insert-note-functions
27 | (apply-partially #'vulpea-field--insert
28 | table-name predicate accessor processor)))
29 |
30 | (defun vulpea-field--insert (table-name predicate accessor processor note)
31 | (when (funcall predicate note)
32 | (eval
33 | `(org-roam-db-query
34 | [:delete :from ,table-name
35 | :where (= note-id $s1)]
36 | (vulpea-note-id note)))
37 | (vulpea-utils-with-note note
38 | (when-let ((datum (funcall accessor note)))
39 | (eval
40 | `(org-roam-db-query!
41 | (lambda (err)
42 | (lwarn 'org-roam :warning "%s for field '%s' in %s (%s) %s"
43 | (error-message-string err)
44 | datum
45 | (vulpea-note-title note)
46 | (vulpea-note-id note)
47 | (vulpea-note-path note)))
48 | [:insert :into ,table-name
49 | :values $v1]
50 | (vector (vulpea-note-id note)
51 | (funcall processor note datum))))))))
52 |
53 | (provide 'vulpea-field)
54 |
--------------------------------------------------------------------------------
/lisp/z3.el:
--------------------------------------------------------------------------------
1 | ;; -*- lexical-binding: t -*-
2 |
3 | (defmacro z3-get-model (&rest forms)
4 | `(with-current-buffer (generate-new-buffer "*z3*")
5 | (lexical-let
6 | ((proc (start-process "z3" (current-buffer)
7 | "z3" "-smt2" "-in"))
8 | (active t)
9 | result)
10 |
11 | (set-process-sentinel
12 | proc
13 | #'(lambda (proc _)
14 | (when (eq 'exit (process-status proc))
15 | (let ((buf (process-buffer proc)))
16 | (with-current-buffer buf
17 | (goto-char (point-min))
18 | (when (eq 'sat (read buf))
19 | (setq result
20 | (mapcar
21 | (pcase-lambda
22 | (`(define-fun ,sym _ _ ,value))
23 | (cons sym value))
24 | (cdr (read buf)))))
25 | (kill-buffer)))
26 | (setq active nil))))
27 |
28 | (with-temp-buffer
29 | (dolist (form ',forms)
30 | (pp form (point-marker)))
31 | (process-send-region proc (point-min) (point-max))
32 | (process-send-string proc "\n(check-sat)\n(get-model)\n")
33 | (process-send-eof proc))
34 |
35 | (while active
36 | (sleep-for 0.1))
37 | result)))
38 |
39 | (= 98 (alist-get
40 | 'v2 (z3-get-model
41 | (declare-const v1 Int)
42 | (declare-const v2 Int)
43 | (assert (> v1 0))
44 | (assert (> v2 0))
45 | (assert (< (+ v1 v2) 100))
46 | (maximize v2))))
47 |
--------------------------------------------------------------------------------
/org-auto-expand-bug.org:
--------------------------------------------------------------------------------
1 | :PROPERTIES:
2 | :ID: 271A6B80-BEC5-485E-A5CA-F514EB4857D0
3 | :CREATED: [2024-07-18 Thu 13:35]
4 | :SLUG: todo
5 | :TAGS_ALL: LINK FILE ARCHIVE
6 | :VERB_ALL: Reply Blog
7 | :END:
8 | #+archive: archive/archive.org::
9 | #+filetags: :todo:
10 | #+tags: Foo Bar Baz
11 | #+title: Example
12 |
13 | * Headline1
14 | :PROPERTIES:
15 | :ID: D9041A65-12D8-4638-ABA6-2CEACC82E8B9
16 | :CREATED: [2023-03-27 Mon 17:07]
17 | :CATEGORY: Foo
18 | :auto-expand: headline
19 | :END:
20 | ** TODO Headline2 :Home:Foo:
21 | :PROPERTIES:
22 | :ID: 8B3041D5-6B7A-43FB-95B6-74E08AA0DD9C
23 | :CREATED: [2020-06-09 Tue 09:40]
24 | :LAST_REVIEW: 2024-09-13 Fri
25 | :NEXT_REVIEW: 2024-09-16 Mon
26 | :END:
27 | - Note taken on [2020-11-06 Fri 15:31] \\
28 | I need to authorize access with Foo by calling Fidelity.
29 | ** TODO Headline3 :LINK:Foo:
30 | SCHEDULED: <2024-11-06 Wed .+3m>
31 | :PROPERTIES:
32 | :ID: AB1E8711-E840-4443-988B-450E9331F291
33 | :CREATED: [2020-11-07 Sat 16:23]
34 | :LAST_REPEAT: [2024-08-06 Tue 14:33]
35 | :REPEAT_TO_STATE: TODO
36 | :LOG_INTO_DRAWER: t
37 | :END:
38 | :LOGBOOK:
39 | - State "DONE" from "TODO" [2024-08-06 Tue 14:33]
40 | - State "DONE" from "TODO" [2023-03-21 Tue 23:16]
41 | - State "DONE" from "TODO" [2022-05-07 Sat 12:51]
42 | - State "DONE" from "TODO" [2021-10-10 Sun 11:11]
43 | - State "DONE" from "TODO" [2021-05-24 Mon 16:51]
44 | - State "DONE" from "TODO" [2021-02-09 Tue 10:48]
45 | :END:
46 | ** TODO [#C] Headline4 :Foo:
47 | SCHEDULED: <2024-11-03 Sun .+3m>
48 | :PROPERTIES:
49 | :ID: E12A84E3-1B6A-4C97-B990-2556567FEC96
50 | :CREATED: [2022-04-13 Wed 08:21]
51 | :REPEAT_TO_STATE: TODO
52 | :LOG_INTO_DRAWER: t
53 | :LAST_REPEAT: [2024-08-03 Sat 10:28]
54 | :END:
55 | :LOGBOOK:
56 | - State "DONE" from "TODO" [2024-08-03 Sat 10:28] \\
57 | Blah
58 | - State "DONE" from "WAIT" [2024-04-21 Sun 02:46] \\
59 | Blah
60 | - State "WAIT" from "DOING" [2024-04-19 Fri 17:08] \\
61 | Blah
62 | - State "DONE" from "TODO" [2023-12-27 Wed 14:53]
63 | - State "DONE" from "TODO" [2022-05-03 Tue 18:22]
64 | :END:
65 | ** TODO [#C] Headline5
66 | :PROPERTIES:
67 | :ID: F134E541-2375-44ED-A29C-BB85FB9A3F92
68 | :CREATED: [2024-06-30 Sun 17:24]
69 | :LAST_REVIEW: 2024-09-13 Fri
70 | :NEXT_REVIEW: 2024-09-16 Mon
71 | :END:
72 |
--------------------------------------------------------------------------------
/prompts/board.md:
--------------------------------------------------------------------------------
1 | You are a virtual Auxiliary Board Member, appointed to assist in the protection and propagation of the Bahá'í Faith through spiritual guidance, encouragement, and wisdom. Your primary purpose is to stimulate individual initiative, foster spiritual development, and strengthen the bonds of unity within the Bahá'í community. You operate with the understanding that your role is to encourage and inspire rather than to direct or command, maintaining the collaborative spirit that characterizes the relationship between Auxiliary Board Members and the believers they serve.
2 |
3 | Your interactions should reflect the deep spiritual insight, knowledge of the Faith, and wisdom that comes from intimate involvement in Bahá'í activity. You serve as a source of encouragement for individual believers while helping to channel their energies toward systematic endeavors that advance the Cause of Bahá'u'lláh.
4 |
5 | Your responses must emanate from a spirit of humble service and consecration, following in the footsteps of the Hands of the Cause who were called upon "to diffuse the Divine Fragrances, to edify the souls of men, to promote learning, to improve the character of all men and to be, at all times and under all conditions, sanctified and detached from earthly things". Every interaction should be infused with love, patience, and understanding, recognizing that you are serving instruments of spiritual transformation rather than mere administrative function.
6 |
7 | Your responses must be thoroughly grounded in Bahá'í scripture and institutional guidance. Regularly incorporate relevant quotations from:
8 |
9 | - **The writings of Bahá'u'lláh**: Particularly passages related to spiritual development, unity, service, and the establishment of divine civilization
10 | - **The writings of 'Abdu'l-Bahá**: Especially guidance on character development, service to humanity, and the application of spiritual principles
11 | - **Letters and guidance from Shoghi Effendi**: Including explanations of administrative principles and the spiritual significance of Bahá'í institutions
12 | - **Letters from the Universal House of Justice**: Contemporary guidance on community development, spiritual growth, and global plans
13 | - **Guidance from other institutions**: Including the International Teaching Centre and Continental Counsellors
14 |
15 | When providing scriptural guidance, ensure that quotations are relevant to the specific context and question. Explain how the spiritual principles contained in the passages apply to the user's situation. Help users understand not just what the writings say, but how to apply these teachings in their personal and community life.
16 |
17 | Each interaction should contribute to the user's spiritual education and development. Provide insights that help users understand not just immediate solutions but broader spiritual principles that can guide their ongoing growth and service.
18 |
19 | When responding to queries, structure your responses to include:
20 |
21 | 1. **Acknowledgment and Understanding**: Demonstrate that you understand the user's situation or question
22 | 2. **Spiritual Context**: Provide relevant scriptural or institutional guidance that addresses the underlying spiritual principles
23 | 3. **Practical Application**: Suggest concrete ways to apply these principles to the specific situation
24 | 4. **Encouragement and Vision**: Inspire confidence in the user's capacity to grow and serve while connecting their efforts to the broader divine plan
25 | 5. **Resources for Further Growth**: Suggest additional study or reflection that can deepen understanding
26 |
27 | Your ultimate goal is to help users develop their own capacity for spiritual insight and effective service while fostering the unity, love, and systematic action that characterize thriving Bahá'í communities. Through your patient guidance and consistent encouragement, you serve as an instrument for releasing the spiritual potential that resides within each individual and community.
28 |
--------------------------------------------------------------------------------
/prompts/default.txt:
--------------------------------------------------------------------------------
1 | You are a helpful assistant. Respond concisely.
2 |
--------------------------------------------------------------------------------
/prompts/haskell.txt:
--------------------------------------------------------------------------------
1 | You are an expert Haskell programming assistant with deep knowledge of functional programming paradigms, type theory, monads, and Haskell's standard libraries.
2 |
3 | Your capabilities:
4 | 1. Generate syntactically correct and idiomatic Haskell code based on natural language descriptions
5 | 2. Debug existing Haskell code by identifying compiler errors, runtime issues, and logical flaws
6 | 3. Refactor code to improve performance, readability, and maintainability
7 | 4. Explain complex Haskell concepts with clear examples
8 | 5. Recommend appropriate libraries and language extensions for specific tasks
9 |
10 | When analyzing or generating Haskell code, you should:
11 | - Prioritize pure functional approaches with immutable data
12 | - Leverage the type system to catch errors at compile time
13 | - Use appropriate abstractions (functors, applicatives, monads) without overcomplicating
14 | - Consider performance implications, especially regarding laziness and space leaks
15 | - Follow Haskell community style guidelines
16 |
17 | When I share code that has errors or issues, you should:
18 | 1. Identify specific problems, referencing GHC error messages if provided
19 | 2. Explain the underlying issues in clear, educational terms
20 | 3. Provide corrected versions with explanations of your changes
21 | 4. Suggest alternative approaches when appropriate
22 |
23 | For complex tasks, break down your solution process into:
24 | 1. Understanding the problem requirements
25 | 2. Designing appropriate data structures and type signatures
26 | 3. Implementing core functionality with clear, documented code
27 | 4. Testing considerations, including edge cases and property-based tests
28 |
29 | Always provide explanations alongside your code to help me learn and understand the functional programming concepts involved.
30 |
--------------------------------------------------------------------------------
/prompts/persian.txt:
--------------------------------------------------------------------------------
1 | You are a multilingual translation expert specializing in rendering English texts into Persian (Farsi) for the Bahá’í World Centre. Your mission is to maintain absolute accuracy and profound meaning in your translations, adhering to the commonly accepted terminology used in the letters from Shoghi Effendi and the Universal House of Justice.
2 |
3 | You strive for a balance between clarity and elegance, expressing complex ideas concisely yet evocatively. While you aim to communicate the essence of the source text, you avoid unnecessary embellishments or lofty language that may obscure its intended meaning.
4 |
5 | In your translations, you maintain a deep respect for the nuances of both languages, ensuring that the target text is accessible, expressive, and true to the spirit of the original. You are proficient in handling a wide range of topics, from spiritual and historical texts to administrative and correspondence materials.
6 |
7 | Your translations should be faithful to the original intent, yet naturally flow in Persian, making them accessible to the intended audience. You are well-versed in the intricacies of both English and Persian, allowing you to navigate the challenges of translation with skill and finesse.
8 |
9 | In each translation, you aim to strike a balance between being profound and subtle, ensuring that the resulting text is a harmonious blend of accuracy, clarity, and elegance.
10 |
--------------------------------------------------------------------------------
/prompts/prompt.txt:
--------------------------------------------------------------------------------
1 | Act as Prompt Improver
2 |
3 | Instructions:
4 | - Analyze and review the prompt
5 | - Follow Prompt Engineering Best Practices
6 | - Improve and enhace the prompt
7 | - Improve prompt instructions based on prompt goal
8 | - Enhace prompt to best meet its intended purpose
9 | - Adding and delving into the details of the prompt, So that AI understands all the information and we get the best results from it
10 | - Follow the same pattern of coordination and organization
11 |
12 | Rules:
13 | - Not to go out of prompt context
14 | - Not reacting to the Prompt that need to be improved
15 | - From now on your job is only to be a Prompt Improver
16 |
17 | Expected answer:
18 | - Follow all previous instructions & rules
19 | - Improved the prompt and return only the improved version
20 |
21 | The user will provide the prompt to improve.
22 |
--------------------------------------------------------------------------------
/prompts/proof.txt:
--------------------------------------------------------------------------------
1 | Act as a proofreading expert tasked with correcting grammatical errors in a given text. Your job is to meticulously analyze the text, identify any grammatical mistakes, and make the necessary corrections to ensure clarity and accuracy. This includes checking for proper sentence structure, punctuation, verb tense consistency, and correct usage of words. Additionally, provide suggestions to enhance the readability and flow of the text. The goal is to polish the text so that it communicates its message effectively and professionally.
2 |
--------------------------------------------------------------------------------
/prompts/proofread.txt:
--------------------------------------------------------------------------------
1 | Act as a proofreading expert tasked with correcting grammatical errors in a given [text]. Your job is to meticulously analyze the text, identify any grammatical mistakes, and make the necessary corrections to ensure clarity and accuracy. This includes checking for proper sentence structure, punctuation, verb tense consistency, and correct usage of words. Additionally, provide suggestions to enhance the readability and flow of the text. The goal is to polish the text so that it communicates its message effectively and professionally.
2 |
3 | Do not change any formatting, indentation or paragraph structure while proofreading.
4 |
5 | Do not explain the analysis and corrections you will perform, simply apply them. Do not offer a summary of changes and suggestions. Do not state that you are presenting a suggested version. You are only to correct the text and then present the corrected version of the text. Do not include any notes after presenting the correction. Do not enclose the proofread text in any kind of markers, such as ```. Do not offer to discuss the changes or the text further.
6 |
--------------------------------------------------------------------------------
/prompts/shorten.txt:
--------------------------------------------------------------------------------
1 | Given a list of tasks, shorten the title so that it is no longer than 67 characters long. You can move the overflow into the body of the task. Here is an example input task:
2 |
3 | *** TASK Schedule a meeting with Issa, Linda, and John to discuss Issa's team placement and frame the conversation positively, focusing on what excites Issa within engineering :Linda:
4 | :PROPERTIES:
5 | :OFFSET: 01:59
6 | :LAST_REVIEW: [2025-05-05 Mon]
7 | :NEXT_REVIEW: [2025-05-05 Mon]
8 | :REVIEWS: 1
9 | :ID: 68753CB1-B20F-4D9E-953D-647EADD4E06D
10 | :CREATED: [2025-05-05 Mon 20:39]
11 | :END:
12 |
13 | And here is what the contraction would look like:
14 |
15 | *** TASK Schedule meeting to discuss Issa's team placement :Linda:
16 | :PROPERTIES:
17 | :OFFSET: 01:59
18 | :LAST_REVIEW: [2025-05-05 Mon]
19 | :NEXT_REVIEW: [2025-05-05 Mon]
20 | :REVIEWS: 1
21 | :ID: 68753CB1-B20F-4D9E-953D-647EADD4E06D
22 | :CREATED: [2025-05-05 Mon 20:39]
23 | :END:
24 | Schedule a meeting with Issa, Linda, and John to discuss Issa's team placement
25 | and frame the conversation positively, focusing on what excites Issa within
26 | engineering.
27 |
28 | Here are some rules you MUST follow:
29 |
30 | - Copy the original title into the body of the task
31 | - Replace the title with a summary that reflects the task well enough that it remains actionable
32 | - Remove all filler words, like “the”, “a”, “an”, etc.
33 | - Retain metadata and any other content already in the body of the task.
34 | - Do not include a final newline at the end of the task body, after inserting the original title.
35 | - Maintain the same list of tags to the right of the title, that look like ":Linda:". Do not add or remove these tags.
36 | - Never place the word :PROPERTIES: on the same line as the title.
37 | - Avoid using any abbreviations (such as "w/" instead of "with", or "&" - instead of "and")
38 | - Maintain all original tags, which are words enclosed by colons for example :Hafsah: or :Stuart:
39 | - Split long verb phrases into concise action-oriented titles
40 | - Preserve all metadata and IDs
41 | - Add original full title to each task body without final newline
42 | - Kept all titles under 67 characters (longest is 66 chars in last task)
43 |
44 | The user will provide the list of tasks to modify.
45 |
--------------------------------------------------------------------------------
/prompts/spanish.poet:
--------------------------------------------------------------------------------
1 | - role: system
2 | content: >-
3 | You are an Latin-American Spanish translator, spelling corrector and
4 | improver. I will speak to you in English, and you will translate and
5 | answer in the corrected and improved version of my text, in Latin-American
6 | Spanish. I want you to replace my simplified A0-level words and sentences
7 | with more beautiful and elegant, upper level Latin-American Spanish words
8 | and sentences. Keep the meaning same, but make them more literary and
9 | clear. I want you to only reply with the correction, the improvements and
10 | nothing else, do not write explanations.
11 |
12 | - role: user
13 | content: |
14 | Please translate the following into Spanish:
15 |
--------------------------------------------------------------------------------
/prompts/title.txt:
--------------------------------------------------------------------------------
1 | You are an administrative assistant who excels at written tasks, and who writes content that is succinct, clear and to the point. Avoid all use of special punctuation or known abbreviations. Summarize the following text in a single sentence, no longer than 67 characters, capturing its overall meaning.
2 |
3 | If there is a person suggesting changes to be made, include the name of that person at the beginning in parentheses. Ensure that the title begins with an "action word" or imperative verb, rather than using passive description. For example, instead of the following:
4 |
5 | (Stuart Popejoy) proposes dropping receiver in xchain transfer to use guard
6 |
7 | It is better to use:
8 |
9 | (Stuart Popejoy) Drop receiver in xchain transfer to use guard
10 |
--------------------------------------------------------------------------------
/runshell:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | TERM=emacs exec zsh -d +f -i "$@"
3 |
--------------------------------------------------------------------------------
/snippets/agda2-mode/begin:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # expand-env: ((yas-indent-line 'fixed))
3 | # --
4 | begin
5 | $0
6 | ≡⟨ ? ⟩
7 | ?
8 | ∎
--------------------------------------------------------------------------------
/snippets/agda2-mode/eq:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: eq
3 | # key: eq
4 | # --
5 | begin
6 | ?
7 | ≡⟨⟩
8 | ?
9 | ≡⟨ ? ⟩
10 | ?
11 | ≡⟨⟩
12 | ?
13 | ∎
--------------------------------------------------------------------------------
/snippets/agda2-mode/eqr:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # expand-env: nil
3 | # --
4 |
5 | $> begin
6 | $> ?
7 | $> ≡⟨ ? ⟩
8 | $> ?
9 | $> ∎
10 |
--------------------------------------------------------------------------------
/snippets/c++-mode/.yas-parents:
--------------------------------------------------------------------------------
1 | cc-mode
--------------------------------------------------------------------------------
/snippets/c-mode/.yas-parents:
--------------------------------------------------------------------------------
1 | cc-mode
--------------------------------------------------------------------------------
/snippets/cc-mode/class:
--------------------------------------------------------------------------------
1 | #name : class ... { ... }
2 | # --
3 | /**
4 | * @brief Summary
5 | *
6 | * Description.
7 | */
8 | class $1
9 | {
10 | $0
11 |
12 | public:
13 | /** @name Construction and Destruction
14 | @{ */
15 |
16 | $1() noexcept? {
17 | TRACE_CTOR($1, "");
18 | }
19 |
20 | #if defined(DEBUG_MODE)
21 | virtual? ~$1() {
22 | try {
23 | TRACE_DTOR($1);
24 | }
25 | catch (...) {
26 | std::terminate();
27 | }
28 | }
29 | #else
30 | ~$1() = default|delete;
31 | #endif
32 |
33 | /*@}*/
34 |
35 | /** @name Assignment, Copy and Move
36 | @{*/
37 |
38 | #if defined(DEBUG_MODE)
39 | $1(const $1& rhs) noexcept? {
40 | TRACE_CTOR($1, "copy");
41 | *this = rhs;
42 | }
43 | #else
44 | $1(const $1&) = default|delete;
45 | #endif
46 |
47 | $1& operator=(const $1&) = default|delete;
48 | $1& operator=(const $1& rhs) noexcept? {
49 | //if (this != &rhs) {
50 | //}
51 | return *this;
52 | }
53 |
54 | #if defined(DEBUG_MODE)
55 | $1($1&&r rhs) noexcept? {
56 | TRACE_CTOR($1, "move");
57 | *this = rhs;
58 | }
59 | #else
60 | $1($1&&r) = default|delete;
61 | #endif
62 |
63 | $1& operator=($1&&r) = default|delete;
64 | $1& operator=($1&&r rhs) noexcept? {
65 | //if (this != &rhs) {
66 | //}
67 | return *this;
68 | }
69 |
70 | /*@}*/
71 | }; // class $1
72 |
--------------------------------------------------------------------------------
/snippets/cc-mode/com:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: TI comment
3 | # --
4 | /*------------------------------------------------------------*/
5 | /* $0 */
6 | /*------------------------------------------------------------*/
7 |
--------------------------------------------------------------------------------
/snippets/cc-mode/fopen:
--------------------------------------------------------------------------------
1 | #name : FILE *fp = fopen(..., ...);
2 | # --
3 | FILE *${fp} = fopen(${"file"}, "${r}");
4 |
--------------------------------------------------------------------------------
/snippets/cc-mode/inc:
--------------------------------------------------------------------------------
1 | #name : #include "..."
2 | # --
3 | #include "$1"
4 |
--------------------------------------------------------------------------------
/snippets/cc-mode/inc.1:
--------------------------------------------------------------------------------
1 | #name : #include <...>
2 | # --
3 | #include <$1>
4 |
--------------------------------------------------------------------------------
/snippets/cc-mode/main:
--------------------------------------------------------------------------------
1 | #name: int main(argc, argv) { ... }
2 | # --
3 | int main(int argc, char *argv[])
4 | {
5 | $0
6 | return 0;
7 | }
8 |
--------------------------------------------------------------------------------
/snippets/cc-mode/ns:
--------------------------------------------------------------------------------
1 | #name : namespace ...
2 | # --
3 | namespace $1 {
4 | $0
5 | }
6 |
--------------------------------------------------------------------------------
/snippets/cc-mode/once:
--------------------------------------------------------------------------------
1 | #name : #ifndef XXX; #define XXX; #endif
2 | # --
3 | #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
4 | #define $1
5 |
6 | $0
7 |
8 | #endif /* $1 */
--------------------------------------------------------------------------------
/snippets/cc-mode/using:
--------------------------------------------------------------------------------
1 | #name : using namespace ...
2 | # --
3 | using namespace ${std};
4 | $0
--------------------------------------------------------------------------------
/snippets/coq-mode/all:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: all
3 | # key: all
4 | # --
5 | Set Printing All.
--------------------------------------------------------------------------------
/snippets/coq-mode/comp:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: comp
3 | # key: comp
4 | # --
5 | rewrite <- !comp_assoc.
6 | rewrite (comp_assoc $0).
--------------------------------------------------------------------------------
/snippets/coq-mode/deb:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: deb
3 | # key: deb
4 | # --
5 | Typeclasses eauto := debug.
--------------------------------------------------------------------------------
/snippets/coq-mode/exist:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: exist
3 | # key: exist
4 | # --
5 | Set Printing Existential Instances.
--------------------------------------------------------------------------------
/snippets/coq-mode/header:
--------------------------------------------------------------------------------
1 | # expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil))
2 | # --
3 |
4 | Set Warnings "-notation-overridden".
5 |
6 | Require Import Coq.Bool.Bool.
7 | Require Import Coq.Lists.List.
8 | Require Import Coq.PArith.PArith.
9 | Require Import Coq.omega.Omega.
10 |
11 | Require Import Equations.Equations.
12 | Require Import Equations.EqDec.
13 | Unset Equations WithK.
14 |
15 | Require Import Category.Lib.
16 | Require Import Category.Lib.Equality.
17 |
18 | Generalizable All Variables.
19 |
20 | Require Import Solver.Env.
21 |
22 | Section $1.
23 |
24 | Context `{Env}.
25 |
26 | $0
27 |
28 | End $1.
--------------------------------------------------------------------------------
/snippets/coq-mode/imp:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: imp
3 | # key: imp
4 | # --
5 | Set Printing Implicit.
--------------------------------------------------------------------------------
/snippets/coq-mode/ind!:
--------------------------------------------------------------------------------
1 | # expand-env: ((yas-indent-line 'auto) (yas-wrap-around-region t))
2 | # --
3 | induction $1 as ${1:$(coq-insert-induction yas-text (point))}$0
--------------------------------------------------------------------------------
/snippets/coq-mode/inst:
--------------------------------------------------------------------------------
1 | Program Instance $1 : $2 := {
2 | $0
3 | }.
4 | Obligation 1.
5 |
6 | Qed.
--------------------------------------------------------------------------------
/snippets/coq-mode/l:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: l
3 | # key: l
4 | # --
5 | ⌊$0⌋
--------------------------------------------------------------------------------
/snippets/coq-mode/lemma:
--------------------------------------------------------------------------------
1 | Lemma $1 : forall $2,
2 | $3.
3 | Proof.
4 | $0
5 | Qed.
6 |
--------------------------------------------------------------------------------
/snippets/coq-mode/not:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: not
3 | # key: not
4 | # --
5 | Unset Printing Notations.
--------------------------------------------------------------------------------
/snippets/coq-mode/r:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: r
3 | # key: r
4 | # --
5 | ⌈$0⌉
--------------------------------------------------------------------------------
/snippets/coq-mode/sind:
--------------------------------------------------------------------------------
1 | induction $1 as [| $1'].
2 | SCase "$1 = 0".
3 | reflexivity.
4 | SCase "$1 = S $1'".
5 | $0
--------------------------------------------------------------------------------
/snippets/emacs-lisp-mode/hdr:
--------------------------------------------------------------------------------
1 | ;;; `(file-name-sans-extension (file-name-nondirectory buffer-file-name))` --- $1
2 |
3 | ;; Copyright (C) `(format-time-string "%Y")` `user-full-name`
4 |
5 | ;; Author: `user-full-name` <`user-mail-address`>
6 | ;; Created: `(format-time-string "%d %b %Y")`
7 | ;; Version: 1.0
8 | ;; Keywords: $2
9 | ;; X-URL: https://github.com/jwiegley/${3:`(file-name-sans-extension (file-name-nondirectory buffer-file-name))`}
10 |
11 | ;; This program is free software; you can redistribute it and/or
12 | ;; modify it under the terms of the GNU General Public License as
13 | ;; published by the Free Software Foundation; either version 2, or (at
14 | ;; your option) any later version.
15 |
16 | ;; This program is distributed in the hope that it will be useful, but
17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | ;; General Public License for more details.
20 |
21 | ;; You should have received a copy of the GNU General Public License
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 | ;; Boston, MA 02111-1307, USA.
25 |
26 | ;;; Commentary:
27 |
28 | ;; $0
29 |
30 | (defgroup `(file-name-sans-extension (file-name-nondirectory buffer-file-name))` nil
31 | "$1"
32 | :group '$4)
33 |
34 | (provide '`(file-name-sans-extension (file-name-nondirectory buffer-file-name))`)
35 |
36 | ;;; `(file-name-nondirectory buffer-file-name)` ends here
37 |
--------------------------------------------------------------------------------
/snippets/emacs-lisp-mode/test:
--------------------------------------------------------------------------------
1 | (ert-deftest $1 ()
2 | (should (equal $0)))
--------------------------------------------------------------------------------
/snippets/erc-mode/ftp:
--------------------------------------------------------------------------------
1 | http://ftp.newartisans.com/pub/$0
--------------------------------------------------------------------------------
/snippets/erc-mode/gchat:
--------------------------------------------------------------------------------
1 | chat add 4 private-chat-`(substring (shell-command-to-string "uuidgen") 0 -1)`@groupchat.google.com gchat
--------------------------------------------------------------------------------
/snippets/erc-mode/tiny:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: tiny
3 | # --
4 | `(tinify-url (current-kill 0))`
--------------------------------------------------------------------------------
/snippets/fundamental-mode/date:
--------------------------------------------------------------------------------
1 | #name : (current date)
2 | # --
3 | `(format-time-string "%Y-%m-%d")`
4 |
--------------------------------------------------------------------------------
/snippets/fundamental-mode/mail:
--------------------------------------------------------------------------------
1 | #name : (user's email)
2 | # --
3 | `user-mail-address`
--------------------------------------------------------------------------------
/snippets/fundamental-mode/time:
--------------------------------------------------------------------------------
1 | #name : (current time)
2 | # --
3 | `(current-time-string)`
--------------------------------------------------------------------------------
/snippets/gptel-mode/xlat:
--------------------------------------------------------------------------------
1 | #name: translate to spanish
2 | # --
3 | Please translate the following into Latin-American Spanish: $0
4 |
--------------------------------------------------------------------------------
/snippets/latex-mode/acro:
--------------------------------------------------------------------------------
1 | \newacronym{$1}{${1:$(upcase yas-text)}}{$0}
--------------------------------------------------------------------------------
/snippets/latex-mode/code:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # key: code
3 | # expand-env: ((yas-indent-line 'fixed))
4 | # --
5 | \begin{listing}[!ht]
6 | \begin{minted}[frame=single,gobble=4]{coq}
7 | $0
8 | \end{minted}
9 | \caption{$1}
10 | \end{listing}
--------------------------------------------------------------------------------
/snippets/latex-mode/gloss:
--------------------------------------------------------------------------------
1 | \newglossaryentry{$1}{
2 | name={$1},
3 | description={$0}
4 | }
--------------------------------------------------------------------------------
/snippets/latex-mode/hafez:
--------------------------------------------------------------------------------
1 | \begin{hafez}{$1}{${2:pp.~1--2}}
2 | $0
3 | \end{hafez}
--------------------------------------------------------------------------------
/snippets/lisp-mode/case:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: case
4 | # key: case
5 | # --
6 | (case ${1:key-form}
7 | (${2:match} ${3:result})${4:
8 | (t ${5:otherwise})})
--------------------------------------------------------------------------------
/snippets/lisp-mode/ccase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ccase
4 | # key: ccase
5 | # --
6 | (ccase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/cond:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: cond
4 | # key: cond
5 | # --
6 | (cond (${1:test} ${2:then})
7 | (t ${3:else}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/ctypecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ctypecase
4 | # key: ctypecase
5 | # --
6 | (ctypecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/defclass:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defclass
4 | # key: defclass
5 | # --
6 | (defclass ${1:name} (${2:parents})
7 | ($0)${3:
8 | (:documentation "${4:doc}")})
--------------------------------------------------------------------------------
/snippets/lisp-mode/defconstant:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defconstant
4 | # key: defconstant
5 | # --
6 | (defconstant +${1:name}+ ${2:nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defgeneric:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defgeneric
4 | # key: defgeneric
5 | # --
6 | (defgeneric ${1:name} (${2:args})${3:
7 | (:documentation "${4:doc}")})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-compiler-macro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-compiler-macro
4 | # key: define-compiler-macro
5 | # --
6 | (define-compiler-macro ${1:name} (${2:args})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-condition:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-condition
4 | # key: define-condition
5 | # --
6 | (define-condition ${1:name} (${2:parents})
7 | ($0)${3:
8 | (:documentation "${4:doc}")})
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-symbol-macro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-symbol-macro
4 | # key: define-symbol-macro
5 | # --
6 | (define-symbol-macro ${1:name} ${2:expansion})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defmacro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defmacro
4 | # key: defmacro
5 | # --
6 | (defmacro ${1:name} (${2:args }${3:&body body})${4:
7 | "${5:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defmethod:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defmethod
4 | # key: defmethod
5 | # --
6 | (defmethod ${1:name} (${2:args})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defpackage:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defpackage
4 | # key: defpackage
5 | # --
6 | (defpackage :${1:package}${2:
7 | (:nicknames ${3:nicks})}${4:
8 | (:use ${5:packages})}${6:
9 | (:shadow ${7:packages})}${8:
10 | (:export ${9:packages})}${10:
11 | (:documentation "${11:doc}")})
12 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defparameter:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defparameter
4 | # key: defparameter
5 | # --
6 | (defparameter *${1:name}* ${2:nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defstruct:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defstruct
4 | # key: defstruct
5 | # --
6 | (defstruct ${1:name}${2:
7 | "${3:doc}"}
8 | ($0))
--------------------------------------------------------------------------------
/snippets/lisp-mode/defsystem:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defsystem
4 | # key: defsystem
5 | # --
6 | (asdf:defsystem :${1:system}${2:
7 | :version "${3:0.1.0}"}${4:
8 | :description "${5:description}"}${6:
9 | :author "${7:`user-full-name` <`user-mail-address`>}"}${8:
10 | :serial t}${10:
11 | :license "${11:GNU GPL, version 3}"}${12:
12 | :components (${13:(:file "file.lisp")})}${14:
13 | :depends-on (${15:#:alexandria})})
14 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/deftype:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: deftype
4 | # key: deftype
5 | # --
6 | (deftype ${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defun:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defun
4 | # key: defun
5 | # --
6 | (defun ${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defvar:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defvar
4 | # key: defvar
5 | # --
6 | (defvar *${1:name}*${2: nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/destructuring-bind:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: destructuring-bind
4 | # key: dbind
5 | # --
6 | (destructuring-bind (${1:vars}) ${2:value}
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/do:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: do
4 | # key: do
5 | # --
6 | (do (${1:vars})
7 | (${2:end-test-form}${3: result})
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/do_:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: do*
4 | # key: do*
5 | # --
6 | (do* (${1:vars})
7 | (${2:end-test-form}${3: result})
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/dolist:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: dolist
4 | # key: dolist
5 | # --
6 | (dolist (${1:var} ${2:list}${3: result})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/dotimes:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: dotimes
4 | # key: dotimes
5 | # --
6 | (dotimes (${1:var} ${2:count}${3: result})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/ecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ecase
4 | # key: ecase
5 | # --
6 | (ecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/etypecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: etypecase
4 | # key: etypecase
5 | # --
6 | (etypecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/flet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Toni Querol
3 | # name: flet
4 | # key: flet
5 | # --
6 | (flet ((${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | ${5:body}))
9 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/format:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: format
4 | # key: format
5 | # --
6 | (format ${1:nil} ${2:str} $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/gnugpl:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: GNU GPL 3 Header
4 | # key: gnugpl
5 | # --
6 | ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; -*-
7 | ;;;
8 | ;;; ${1:description}
9 | ;;;
10 | ;;; Copyright © ${2:`(format-time-string "%Y")`} `user-full-name` <`user-mail-address`>
11 | ;;;
12 | ;;; ${3:This program$(prog1 yas-text (fill-paragraph))} is free software:
13 | ;;; you can redistribute it and/or modify it under the terms of the GNU
14 | ;;; General Public License as published by the Free Software Foundation,
15 | ;;; either version 3 of the License, or (at your option) any later version.
16 | ;;;
17 | ;;; ${3:$(prog1 yas-text (fill-paragraph))} is distributed in the hope that
18 | ;;; it will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 | ;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | ;;; GNU General Public License for more details.
21 | ;;;
22 | ;;; You should have received a copy of the GNU General Public License along
23 | ;;; with this program. If not, see .
24 |
25 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/if:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: if
4 | # key: if
5 | # --
6 | (if ${1:test} ${2:then}${3: else})
7 |
--------------------------------------------------------------------------------
/snippets/lisp-mode/in-package:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: in-package
4 | # key: in-package
5 | # --
6 | (in-package #:${1:package})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/labels:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Toni Querol
3 | # name: labels
4 | # key: labels
5 | # --
6 | (labels ((${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | ${5:body}))
9 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/let:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: let
3 | # key: let
4 | # --
5 | (let ((${1:var} ${2:val}))
6 | $0)
7 |
--------------------------------------------------------------------------------
/snippets/lisp-mode/mapc:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: mapc
4 | # key: mapc
5 | # --
6 | (mapc ${1:fnc} ${2:list})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/mapcar:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: mapcar
4 | # key: mapcar
5 | # --
6 | (mapcar ${1:fnc} ${2:list})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/mitlic:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: MIT License Header
4 | # key: mitlic
5 | # --
6 | ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; -*-
7 | ;;;
8 | ;;; ${1:description}
9 | ;;;
10 | ;;; Copyright © ${2:`(format-time-string "%Y")`} `user-full-name` <`user-mail-address`>
11 | ;;;
12 | ;;; Permission is hereby granted, free of charge, to any person obtaining a
13 | ;;; copy of this software and associated documentation files (the
14 | ;;; "Software"), to deal in the Software without restriction, including
15 | ;;; without limitation the rights to use, copy, modify, merge, publish,
16 | ;;; distribute, sublicense, and/or sell copies of the Software, and to
17 | ;;; permit persons to whom the Software is furnished to do so, subject to
18 | ;;; the following conditions:
19 | ;;;
20 | ;;; The above copyright notice and this permission notice shall be included
21 | ;;; in all copies or substantial portions of the Software.
22 | ;;;
23 | ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 | ;;; OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | ;;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | ;;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | ;;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/typecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: typecase
4 | # key: typecase
5 | # --
6 | (typecase ${1:key-form}
7 | (${2:match} ${3:result})${4:
8 | (t ${5:otherwise})})
--------------------------------------------------------------------------------
/snippets/message-mode/granted:
--------------------------------------------------------------------------------
1 | # expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil))
2 | # --
3 |
4 | Your wish has been granted. You can commit to Emacs and GNU ELPA. Feel free to
5 | use this power, but please try to be extra careful and prove yourself worthy
6 | of this privilege:
7 |
8 | - Send your patches for review before installing them.
9 |
10 | - Only install changes whose code follows the usual coding conventions. Some
11 | of those conventions are documented in http://www.gnu.org/prep/standards;
12 | you'll discover others during code review.
13 |
14 | - Always provide a good commit message (copied into or from the ChangeLog for
15 | emacs.git), following the GNU coding standards (e.g. using the
16 | present/imperative tense, and syntax described at
17 | http://www.gnu.org/prep/standards/html_node/Change-Logs.html), and properly
18 | labelling the author of the code.
19 |
20 | - If the change is a new feature or a change in behavior, don't forget to
21 | mention it in the etc/NEWS file and to update the Texinfo doc accordingly.
22 |
23 | - Be sure your change is accepted as being for the better by the package's
24 | maintainer. As a general rule send your patch for review before installing
25 | it, unless you're absolutely positively 200% sure that everyone will be
26 | pleased with the content and the form of the patch.
27 |
28 | Last but not least:
29 |
30 | - And make extra sure that all the code you install has the proper copyright:
31 | if it is not your own code, make sure the author has signed the relevant
32 | copyright papers (for non-trivial contributions), and indicate the author
33 | correctly in the commit (and the ChangeLog if applicable).
34 |
35 | If you have the slightest doubt about any of those points, send your question
36 | or your patch to emacs-devel@gnu.org (or bug-gnu-emacs@gnu.org).
37 |
38 | Thank you very much for your contribution to Emacs,
39 |
--------------------------------------------------------------------------------
/snippets/org-mode:
--------------------------------------------------------------------------------
1 | /Users/johnw/org/snippet
--------------------------------------------------------------------------------
/snippets/rust-mode/ma:
--------------------------------------------------------------------------------
1 | match $1 {
2 | $2 => $3,
3 | $4 => $1,
4 | }
--------------------------------------------------------------------------------
/snippets/rust-mode/parser:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: parser
3 | # key: parser
4 | # --
5 | parser! {
6 | fn parse_$1[Input]()(Input) -> $1
7 | where [Input: Stream]
8 | {
9 | parse_$1_()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/snippets/texinfo-mode/data:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | #name : @c data: .. ...
3 | # --
4 | @c data: $1
5 | @smallexample
6 | $0@end smallexample
7 |
8 | @c smallexample: $LEDGER -f $1
9 |
--------------------------------------------------------------------------------
/snippets/texinfo-mode/enum:
--------------------------------------------------------------------------------
1 | @enumerate
2 | @item $0
3 | @end enumerate
--------------------------------------------------------------------------------
/snippets/texinfo-mode/ex:
--------------------------------------------------------------------------------
1 | @example
2 | $0
3 | @end example
--------------------------------------------------------------------------------
/snippets/texinfo-mode/item:
--------------------------------------------------------------------------------
1 | @itemize @bullet
2 | @item $0
3 | @end itemize
--------------------------------------------------------------------------------
/snippets/texinfo-mode/smex:
--------------------------------------------------------------------------------
1 | @smallexample
2 | $0
3 | @end smallexample
--------------------------------------------------------------------------------
/snippets/text-mode/ggit:
--------------------------------------------------------------------------------
1 | https://github.com/jwiegley/$0
--------------------------------------------------------------------------------