From 1da72be6d140314578f66a03345245694886cd34 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 13 Aug 2015 22:25:20 -0700 Subject: [PATCH] add AHK and Emacs lozenge shortcuts to docs (closes #73) --- scribblings/command.scrbl | 64 +++++++++++++++++++++++++++++++++++++++ scribblings/mb-tools.rkt | 3 +- scribblings/mb.css | 7 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/scribblings/command.scrbl b/scribblings/command.scrbl index 7d52122..2acc00c 100644 --- a/scribblings/command.scrbl +++ b/scribblings/command.scrbl @@ -35,6 +35,70 @@ Still, if you don't want to use the lozenge as your command character, you can s But don't knock the lozenge till you try it. +@subsection{Lozenge helpers} + + +@subsubsection{AHK script} + +Courtesy of @link["https://github.com/maphew"]{Matt Wilkie}: ``Here's a working AHK script to have double-tap backtick send the lozenge character. It took way more time than I want to think about, once started I couldn't let go.'' + +@fileblock["tick-tick-lozenge.ahk"]{ +@foreign-code{ +; +; Double-tap backtick sends Pollen command character (◊) +; For some reason I needed to use Unicode 'U+25CA' +; instead of the standard alt-code '9674' +; +; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm +; and http://www.autohotkey.com/board/topic/145507-how-to-use-double-tap-backtick-with-pass-through/ +; +#EscapeChar \ +$`:: +if winc_presses > 0 + {winc_presses += 1 + return + } + +winc_presses = 1 +SetTimer, TheKey, 250 ; Wait for more presses, in milliseconds +return + +TheKey: + SetTimer, TheKey, off + if winc_presses = 1 ; The key was pressed once. + {Send ` + } + else if winc_presses = 2 ; The key was pressed twice. + {Send {U+25CA} + } + +; Regardless of which action above was triggered, reset the count to +; prepare for the next series of presses: +winc_presses = 0 +return}} + + +@subsubsection{Emacs script} + +Courtesy of @link["https://github.com/lerichard95"]{Richard Le}: ``If you're using Emacs, I tried to write a tiny function that inserts the lozenge character. I chose M-\ because that's the key for the lambda character in DrRacket.'' + +@foreign-code{ +;; Put this in your Emacs .init file: +;; enable lozenge for Pollen +;; ◊◊◊◊◊◊◊◊◊◊◊◊◊ +;; 'mule-unicode part from +;; https://lists.gnu.org/archive/html//emacs-devel/2005-03/msg01187.html +(defun insert-lozenge () + "inserts the lozenge character for use with Pollen" + ;; enables function through M-x + (interactive) + ;; insert the proper character + (insert (make-char + 'mule-unicode-2500-33ff 34 42))) + +;; Bind key to M-\ a la DrRacket for lambda +(global-set-key "\M-\\" 'insert-lozenge)} + @;-------------------------------------------------------------------- @section{The two command modes: text mode & Racket mode} diff --git a/scribblings/mb-tools.rkt b/scribblings/mb-tools.rkt index 70a8801..a27bced 100644 --- a/scribblings/mb-tools.rkt +++ b/scribblings/mb-tools.rkt @@ -35,7 +35,8 @@ (define (errorblock . args) (nested (racketerror (racketfont* (convert-newlines args))))) - +(define (foreign-code . args) + (compound-paragraph (style "foreign-code" (list (css-style-addition mb-css) (alt-tag "div"))) (list (apply verbatim args)))) (define (terminal . args) (compound-paragraph (style "terminal" (list (css-style-addition mb-css) (alt-tag "div"))) (list (apply verbatim args)))) diff --git a/scribblings/mb.css b/scribblings/mb.css index 69332e0..044b31f 100644 --- a/scribblings/mb.css +++ b/scribblings/mb.css @@ -44,3 +44,10 @@ color: #666; } +.foreign-code { + margin-bottom: 1em; + padding: 0.5em; + background: #fcfcfc; + color: #666; +} +