Skip to content

Instantly share code, notes, and snippets.

View fuxialexander's full-sized avatar

Xi "Alexander" Fu fuxialexander

View GitHub Profile
@fuxialexander
fuxialexander / org-ref-skim.el
Last active April 6, 2023 11:48
Integration between Org-ref and Skim.app [Skim Annotation <-> Org Bidirectional Jump]
(setq org-capture-templates (quote (("SA" "Skim Annotation" entry
(file+function org-ref-bibliography-notes my-org-move-point-to-capture-skim-annotation)
"* %^{Logging for...} :skim_annotation:read:literature:
:PROPERTIES:
:Created: %U
:CITE: cite:%(my-as-get-skim-bibtex-key)
:SKIM_NOTE: %(my-org-mac-skim-get-page)
:SKIM_PAGE: %(my-as-get-skim-page)
:END:
%i
tell application "Skim"
set thedoc to the front document
set anno to the active note of thedoc
set newtext to text of anno
set startpoint to (offset of "org-id:{" in newtext) + 8
set endpoint to (offset of "}:org-id" in newtext) - 1
if (startpoint - 8 is not equal to endpoint + 1) and (endpoint + 1 is not 0) then
set orgid to characters startpoint thru endpoint of newtext as string
do shell script "/usr/local/bin/emacsclient -n -e \"(progn (org-id-goto \\\"" & orgid & "\\\") (x-focus-frame (selected-frame)) (evil-exit-visual-state))\""
end if
@fuxialexander
fuxialexander / company-childframe.el
Last active March 12, 2021 15:59
company-childframe.el [adapted from @tumashu for mac os (GNU NS-port HEAD)]
;;; company-childframe.el --- Use a real ppup to show company candidates
;;; Commentary:
;;
;;; Code:
(require 'company)
(defvar company-childframe-child-frame nil)
@fuxialexander
fuxialexander / helm-child-frame-display.el
Last active March 29, 2018 05:41
Override helm function to use child-frame
(defun my-helm-display-child-frame (buffer &optional resume)
"Display `helm-buffer' in a separate frame.
Function suitable for `helm-display-function',
`helm-completion-in-region-display-function'
and/or `helm-show-completion-default-display-function'.
See `helm-display-buffer-height' and `helm-display-buffer-width' to
configure frame size."
(if (not (display-graphic-p))
@fuxialexander
fuxialexander / karabiner.json
Created March 22, 2018 08:15
karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": false,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@fuxialexander
fuxialexander / org-date-hack.el
Last active April 1, 2018 16:47
org-date hack
(setq org-ts-regexp-both-braket "\\([[<]\\)\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]
\n>]*?\\)\\([]>]\\)")
(defun *org-set-font-lock-defaults ()
"Set font lock defaults for the current buffer."
(let* ((em org-fontify-emphasized-text)
(lk org-highlight-links)
(org-font-lock-extra-keywords
(list
;; Call the hook
'(org-font-lock-hook)
@fuxialexander
fuxialexander / katex.el
Last active April 12, 2018 17:03
Instant latex preview in org mode
;; (org-inside-LaTeX-fragment-p)
(require 'xwidget)
(defvar katex-url "file:///PATH/TO/katex.html?")
(defvar katex-buffer nil)
(defvar katex-xw nil)
(setq katex-buffer (get-buffer-create "*xwidget webkit: Katex *"))
(defun org-katex-latex-fragment-maybe (&optional arg)
"TODO"
(if (org-inside-LaTeX-fragment-p)
@fuxialexander
fuxialexander / ob-ipython-hack.el
Created April 11, 2018 01:35
ob-ipython remote kernel hack
(use-package ob-ipython
:after (org ob)
:config (setq ob-ipython-resources-dir ".ob-ipython-resrc/")
(defvar jupyter-local-runtime-dir (substring (shell-command-to-string (concat "jupyter --runtime-dir")) 0 -1))
(defun ob-ipython-generate-local-path-from-remote (session host params)
"Copy remote config to local, start a jupyter console to generate a new one."
(let* ((runtime-dir (substring (shell-command-to-string
(concat "ssh " host " jupyter --runtime-dir")) 0 -1))
(runtime-file (concat runtime-dir "/" "kernel-" session ".json"))
(tramp-path (concat "/ssh:" host ":" runtime-file))
@fuxialexander
fuxialexander / 0_all_webkit.patch
Last active October 7, 2018 08:46
One-stop patch for Emacs NS-port xwidget (by @veshboo)
From 2063aad860376419d899d1ae06ccb7daf56ef9ef Mon Sep 17 00:00:00 2001
From: Jaesup Kwak <veshboo@gmail.com>
Date: Mon, 4 Dec 2017 21:23:19 +0900
Subject: [PATCH] Support xwidget webkit for macOS X
Add xwidget webkit support for macOS X / NS Cocoa and accompanying
changes.
Squash changes for comments from Alan Third in Bug#29565.
(set! :popup "^\\(?: ?\\*\\)?magit.*: "
'((slot . -1) (side . right) (size . 80))
'((select . t) (quit . nil)))
(set! :popup "^\\*magithub-dash\\*"
'((slot . -3) (side . right) (window-height . 20))
'((select . t)))
(def-modeline-segment! magithub-buffer-info-simple
"striped magithub buffer name"
(substring (buffer-name) 11 -1))