Skip to content

Instantly share code, notes, and snippets.

@yuhan0
yuhan0 / clojure-comment-block.el
Created April 21, 2021 10:29
Mark clojure comment blocks in fringes
;;; clojure-comment-block.el --- mark comment blocks in the fringe -*- lexical-binding: t; -*-
;; This is free and unencumbered software released into the public domain.
;;
;; Anyone is free to copy, modify, publish, use, compile, sell, or
;; distribute this software, either in source code form or as a compiled
;; binary, for any purpose, commercial or non-commercial, and by any
;; means.
;;
;; In jurisdictions that recognize copyright laws, the author or authors
@yuhan0
yuhan0 / evil-refresh-cursor.el
Created March 19, 2019 14:18
rate limit evil-refresh-cursor
(defvar evil--refresh-cursor-last-executed 0
"Unix time of when the evil cursor was last refreshed")
(defvar evil-refresh-cursor-delay 0.1
"Max delay in seconds between each cursor refresh")
(defvar evil--refresh-cursor-current-timer nil
"Current timer keeping track of cursor refresh changes")
(defvar evil--refresh-cursor-delayed-specs nil
"Cons pair of cursor (state . buffer) to set after the delay")
@yuhan0
yuhan0 / clojure-toggle-ignore.el
Last active April 24, 2020 11:35
Toggle Clojure #_ ignore forms in Emacs
(defun clojure--toggle-ignore-next-sexp (&optional n)
"Insert or delete N `#_' ignore macros at the current point.
Point must be directly before a sexp or the #_ characters.
When acting on a top-level form it inserts #_ on a new line
preceding the form."
(let ((rgx (rx-to-string `(repeat ,(or n 1) (seq "#_" (* (in "\r\n" blank)))))))
(backward-prefix-chars)
(skip-chars-backward "#_")
(cond
((looking-at rgx) ;; point is before #_
@yuhan0
yuhan0 / packages.el
Created December 31, 2018 16:24
Excerpt from WIP Spacemacs outshine layer
;;; Outshine
(defun outshine/init-outshine ()
(use-package outshine
:defer t
:commands (outshine-reveal-context outshine-mode)
:init
(progn
;; Enable outshine-mode for *all* programming buffers.
;; note - this enables outline-minor-mode at the same time.
(add-hook 'prog-mode-hook 'outshine-mode)
@yuhan0
yuhan0 / auto_annotate.py
Created April 4, 2018 03:51
Adds keyword-argument style parameters to Grasshopper components. Copy and paste this code into an empty GhPython component, it should automatically setup input parameters
"""
Adds annotations to internalized input parameters for all components on the canvas.
using the format `X=Y`. Completely reversible via toggling the `enable` input.
Default enabled types are Boolean, Integer, Number, String, Interval, and Plane,
connect a Value List to the `types` input to enable others.
"""
from Grasshopper.Kernel import Types, Parameters, GH_Component
from Grasshopper.Kernel.Special import GH_ValueList, GH_ValueListItem, GH_ValueListMode
this = ghenv.Component
@yuhan0
yuhan0 / fix_multiline_panels.ghx
Last active April 3, 2018 03:26
Paste directly into Grasshopper canvas to fix multiline panel number parsing issue on Mac. C# component auto-destructs after executing.
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Archive name="Root"><!--Grasshopper archive--><!--Grasshopper and GH_IO.dll are copyrighted by Robert McNeel & Associates--><!--Archive generated by GH_IO.dll file utility library {0.2.0002}--><items count="1"><item name="ArchiveVersion" type_name="gh_version" type_code="80"><Major>0</Major><Minor>2</Minor><Revision>2</Revision></item></items><chunks count="1"><chunk name="Clipboard"><items count="1"><item name="plugin_version" type_name="gh_version" type_code="80"><Major>0</Major><Minor>9</Minor><Revision>80</Revision></item></items><chunks count="3"><chunk name="DocumentHeader"><items count="5"><item name="DocumentID" type_name="gh_guid" type_code="9">9a66f130-89e9-4d3d-9fb1-30aaebdeb37d</item><item name="Preview" type_name="gh_string" type_code="10">Shaded</item><item name="PreviewMeshType" type_name="gh_int32" type_code="3">1</item><item name="PreviewNormal" type_name="gh_drawing_color" type_code="36"><ARGB>100;150;0;0</ARGB></item><item name="Previe