Remove modules/contrib/*; add openwith to Caskfile
This commit is contained in:
parent
57e19dde88
commit
5cc5adfecb
3 changed files with 1 additions and 327 deletions
1
Cask
1
Cask
|
@ -21,6 +21,7 @@
|
||||||
;; OSX --- core/core-os-osx.el
|
;; OSX --- core/core-os-osx.el
|
||||||
(depends-on "exec-path-from-shell")
|
(depends-on "exec-path-from-shell")
|
||||||
(depends-on "dash-at-point")
|
(depends-on "dash-at-point")
|
||||||
|
(depends-on "openwith")
|
||||||
|
|
||||||
;; Popups --- core/core-popup.el
|
;; Popups --- core/core-popup.el
|
||||||
(depends-on "shackle")
|
(depends-on "shackle")
|
||||||
|
|
|
@ -1,207 +0,0 @@
|
||||||
;;; ob-rust.el --- org-babel functions for rust
|
|
||||||
|
|
||||||
;; Author: Philip Munksgaard
|
|
||||||
;; Keywords: literate programming, reproducible research
|
|
||||||
;; Homepage: http://orgmode.org
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; Org-Babel support for evaluating rust code.
|
|
||||||
;;
|
|
||||||
;; This is simply an adaptation of ob-C.el that instead targets rust code.
|
|
||||||
;; Thanks to the original creators Eric Schulte and Thierry Banel
|
|
||||||
;;
|
|
||||||
;; Very limited implementation:
|
|
||||||
;; - currently only support :results output
|
|
||||||
;; - not much in the way of error feedback
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
(eval-when-compile
|
|
||||||
(require 'cl))
|
|
||||||
(require 'ob)
|
|
||||||
(require 'cc-mode)
|
|
||||||
|
|
||||||
(declare-function org-entry-get "org"
|
|
||||||
(pom property &optional inherit literal-nil))
|
|
||||||
|
|
||||||
|
|
||||||
(defvar org-babel-tangle-lang-exts)
|
|
||||||
(add-to-list 'org-babel-tangle-lang-exts '("rust"))
|
|
||||||
|
|
||||||
(defvar org-babel-default-header-args:rust '())
|
|
||||||
|
|
||||||
(defvar org-babel-rust-compiler "rustc"
|
|
||||||
"Command used to compile a rust source code file into an
|
|
||||||
executable.")
|
|
||||||
|
|
||||||
(defun org-babel-expand-body:rust (body params)
|
|
||||||
(org-babel-rust-expand body params))
|
|
||||||
|
|
||||||
(defun org-babel-execute:rust (body params)
|
|
||||||
"Execute a block of rust code with org-babel.
|
|
||||||
This function is called by `org-babel-execute-src-block'."
|
|
||||||
(print body)
|
|
||||||
(princ params)
|
|
||||||
(let* ((tmp-src-file (org-babel-temp-file
|
|
||||||
"rust-src-"
|
|
||||||
".rs"))
|
|
||||||
(tmp-bin-file (org-babel-temp-file "rust-bin-" org-babel-exeext))
|
|
||||||
(cmdline (cdr (assoc :cmdline params)))
|
|
||||||
(flags (cdr (assoc :flags params)))
|
|
||||||
(full-body (org-babel-rust-expand body params))
|
|
||||||
(compile
|
|
||||||
(progn
|
|
||||||
(with-temp-file tmp-src-file (insert full-body))
|
|
||||||
(org-babel-eval
|
|
||||||
(format "%s -o %s %s %s"
|
|
||||||
org-babel-rust-compiler
|
|
||||||
(org-babel-process-file-name tmp-bin-file)
|
|
||||||
(mapconcat 'identity
|
|
||||||
(if (listp flags) flags (list flags)) " ")
|
|
||||||
(org-babel-process-file-name tmp-src-file)) ""))))
|
|
||||||
(let ((results
|
|
||||||
(org-babel-trim
|
|
||||||
(org-babel-eval
|
|
||||||
(concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))
|
|
||||||
(org-babel-reassemble-table
|
|
||||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
|
||||||
(org-babel-read results)
|
|
||||||
(let ((tmp-file (org-babel-temp-file "rust-")))
|
|
||||||
(with-temp-file tmp-file (insert results))
|
|
||||||
(org-babel-import-elisp-from-file tmp-file)))
|
|
||||||
(org-babel-pick-name
|
|
||||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
|
||||||
(org-babel-pick-name
|
|
||||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
|
|
||||||
))
|
|
||||||
|
|
||||||
(defun org-babel-rust-expand (body params)
|
|
||||||
"Expand a block of rust code with org-babel."
|
|
||||||
(print params)
|
|
||||||
(print body)
|
|
||||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
|
||||||
(main-p (not (string= (cdr (assoc :main params)) "no")))
|
|
||||||
(uses (or (cdr (assoc :uses params))
|
|
||||||
(org-babel-read (org-entry-get nil "uses" t))))
|
|
||||||
(externs (org-babel-read
|
|
||||||
(or (cdr (assoc :externs params))
|
|
||||||
(org-babel-read (org-entry-get nil "externs" t)))))
|
|
||||||
(attributes (org-babel-read
|
|
||||||
(or (cdr (assoc :attributes params))
|
|
||||||
(org-babel-read (org-entry-get nil "attributes" t))))))
|
|
||||||
(mapconcat 'identity
|
|
||||||
(list
|
|
||||||
;; attributes
|
|
||||||
(mapconcat
|
|
||||||
(lambda (attr) (format "#[%s]" attr))
|
|
||||||
(if (listp attributes) attributes (list attributes)) "\n")
|
|
||||||
;; externs
|
|
||||||
(mapconcat
|
|
||||||
(lambda (ext) (format "extern crate %s;" ext))
|
|
||||||
(if (listp externs) externs (list externs)) "\n")
|
|
||||||
;; uses
|
|
||||||
(mapconcat
|
|
||||||
(lambda (use) (format "use %s;" use))
|
|
||||||
(if (listp uses) uses (list uses)) "\n")
|
|
||||||
;; variables
|
|
||||||
(mapconcat 'org-babel-rust-var-to-rust vars "\n")
|
|
||||||
;; body
|
|
||||||
(if main-p
|
|
||||||
(org-babel-rust-ensure-main-wrap body)
|
|
||||||
body) "\n") "\n")))
|
|
||||||
|
|
||||||
(defun org-babel-rust-ensure-main-wrap (body)
|
|
||||||
"Wrap BODY in a \"main\" function call if none exists."
|
|
||||||
(if (string-match "[ \t]*fn+[ \t\n\r]*main[ \t]*(.*)" body)
|
|
||||||
body
|
|
||||||
(format "fn main() {\n%s\n}\n" body)))
|
|
||||||
|
|
||||||
(defun org-babel-prep-session:rust (session params)
|
|
||||||
"This function does nothing as rust is a compiled language with no
|
|
||||||
support for sessions"
|
|
||||||
(error "rust is a compiled languages -- no support for sessions"))
|
|
||||||
|
|
||||||
(defun org-babel-load-session:rust (session body params)
|
|
||||||
"This function does nothing as rust is a compiled language with no
|
|
||||||
support for sessions"
|
|
||||||
(error "rust is a compiled languages -- no support for sessions"))
|
|
||||||
|
|
||||||
;; helper functions
|
|
||||||
|
|
||||||
(defun org-babel-rust-format-val (type val)
|
|
||||||
"Handle the FORMAT part of TYPE with the data from VAL."
|
|
||||||
(let ((format-data (cadr type)))
|
|
||||||
(if (stringp format-data)
|
|
||||||
(cons "" (format format-data val))
|
|
||||||
(funcall format-data val))))
|
|
||||||
|
|
||||||
(defun org-babel-rust-val-to-rust-type (val)
|
|
||||||
"Determine the type of VAL.
|
|
||||||
Return a list (TYPE-NAME FORMAT). TYPE-NAME should be the name of the type.
|
|
||||||
FORMAT can be either a format string or a function which is called with VAL."
|
|
||||||
(cond
|
|
||||||
((integerp val) '("int" "%d"))
|
|
||||||
((floatp val) '("f64" "%f"))
|
|
||||||
((or (listp val) (vectorp val))
|
|
||||||
(lexical-let ((type (org-babel-rust-val-to-rust-list-type val)))
|
|
||||||
(list (concat "&'static [" (car type) "]")
|
|
||||||
(lambda (val)
|
|
||||||
(cons
|
|
||||||
(format "[%d]%s"
|
|
||||||
(length val)
|
|
||||||
(car (org-babel-rust-format-val type (elt val 0))))
|
|
||||||
(concat "&["
|
|
||||||
(mapconcat (lambda (v)
|
|
||||||
(cdr (org-babel-rust-format-val type v)))
|
|
||||||
val
|
|
||||||
", ")
|
|
||||||
"]"))))))
|
|
||||||
(t ;; treat unknown types as string
|
|
||||||
'("&'static str" (lambda (val)
|
|
||||||
(let ((s (format "%s" val))) ;; convert to string for unknown types
|
|
||||||
(cons (format "[%d]" (1+ (length s)))
|
|
||||||
(concat "\"" s "\""))))))))
|
|
||||||
|
|
||||||
(defun org-babel-rust-val-to-rust-list-type (val)
|
|
||||||
"Determine the rust array type of a VAL."
|
|
||||||
(let (type)
|
|
||||||
(mapc
|
|
||||||
#'(lambda (i)
|
|
||||||
(let* ((tmp-type (org-babel-rust-val-to-rust-type i))
|
|
||||||
(type-name (car type))
|
|
||||||
(tmp-type-name (car tmp-type)))
|
|
||||||
(when (and type (not (string= type-name tmp-type-name)))
|
|
||||||
(if (and (member type-name '("int" "f64"))
|
|
||||||
(member tmp-type-name '("int" "f64")))
|
|
||||||
(setq tmp-type '("f64" "" "%f"))
|
|
||||||
(error "Only homogeneous lists are supported by rust. You can not mix %s and %s"
|
|
||||||
type-name
|
|
||||||
tmp-type-name)))
|
|
||||||
(setq type tmp-type)))
|
|
||||||
val)
|
|
||||||
type))
|
|
||||||
|
|
||||||
(defun org-babel-rust-var-to-rust (pair)
|
|
||||||
"Convert an elisp val into a string of rust code specifying a var
|
|
||||||
of the same value."
|
|
||||||
;; TODO list support
|
|
||||||
(let ((var (car pair))
|
|
||||||
(val (cdr pair)))
|
|
||||||
(when (symbolp val)
|
|
||||||
(setq val (symbol-name val))
|
|
||||||
(when (= (length val) 1)
|
|
||||||
(setq val (string-to-char val))))
|
|
||||||
(let* ((type-data (org-babel-rust-val-to-rust-type val))
|
|
||||||
(type (car type-data))
|
|
||||||
(formated (org-babel-rust-format-val type-data val))
|
|
||||||
;; (suffix (car formated))
|
|
||||||
(data (cdr formated)))
|
|
||||||
(format "static %s: %s = %s;"
|
|
||||||
var
|
|
||||||
type
|
|
||||||
;suffix
|
|
||||||
data))))
|
|
||||||
|
|
||||||
(provide 'ob-rust)
|
|
||||||
|
|
||||||
;;; ob-rust.el ends here
|
|
|
@ -1,120 +0,0 @@
|
||||||
;;; openwith.el --- Open files with external programs
|
|
||||||
|
|
||||||
;; Copyright (C) 2007, 2013 Markus Triska
|
|
||||||
|
|
||||||
;; Author: Markus Triska <markus.triska@gmx.at>
|
|
||||||
;; Keywords: files, processes
|
|
||||||
|
|
||||||
;; This file is free software; you can redistribute it and/or modify
|
|
||||||
;; it under the terms of the GNU General Public License as published by
|
|
||||||
;; the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
;; any later version.
|
|
||||||
|
|
||||||
;; This file is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
;; GNU General Public License for more details.
|
|
||||||
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
|
||||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
||||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
;; Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; This lets you associate external applications with files so that
|
|
||||||
;; you can open them via C-x C-f, with RET in dired, etc.
|
|
||||||
|
|
||||||
;; Copy openwith.el to your load-path and add to your .emacs:
|
|
||||||
|
|
||||||
;; (require 'openwith)
|
|
||||||
;; (openwith-mode t)
|
|
||||||
|
|
||||||
;; To customize associations etc., use:
|
|
||||||
;;
|
|
||||||
;; M-x customize-group RET openwith RET
|
|
||||||
;;
|
|
||||||
;; To prevent openwith-mode from interfering with attachments when
|
|
||||||
;; writing a message in Gnus, add the following to your .emacs:
|
|
||||||
;;
|
|
||||||
;; (require 'mm-util)
|
|
||||||
;; (add-to-list 'mm-inhibit-file-name-handlers 'openwith-file-handler)
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
|
|
||||||
(defconst openwith-version "0.8g")
|
|
||||||
|
|
||||||
(defgroup openwith nil
|
|
||||||
"Associate external applications with file name patterns."
|
|
||||||
:group 'files
|
|
||||||
:group 'processes)
|
|
||||||
|
|
||||||
(defcustom openwith-associations
|
|
||||||
'(("\\.pdf\\'" "acroread" (file))
|
|
||||||
("\\.mp3\\'" "xmms" (file))
|
|
||||||
("\\.\\(?:mpe?g\\|avi\\|wmv\\)\\'" "mplayer" ("-idx" file))
|
|
||||||
("\\.\\(?:jp?g\\|png\\)\\'" "display" (file)))
|
|
||||||
"Associations of file patterns to external programs.
|
|
||||||
File pattern is a regular expression describing the files to
|
|
||||||
associate with a program. The program arguments are a list of
|
|
||||||
strings and symbols and are passed to the program on invocation,
|
|
||||||
where the symbol 'file' is replaced by the file to be opened."
|
|
||||||
:group 'openwith
|
|
||||||
:type '(repeat (list (regexp :tag "Files")
|
|
||||||
(string :tag "Program")
|
|
||||||
(sexp :tag "Parameters"))))
|
|
||||||
|
|
||||||
(defcustom openwith-confirm-invocation nil
|
|
||||||
"Ask for confirmation before invoking external programs."
|
|
||||||
:group 'openwith
|
|
||||||
:type 'boolean)
|
|
||||||
|
|
||||||
(defun openwith-file-handler (operation &rest args)
|
|
||||||
"Open file with external program, if an association is configured."
|
|
||||||
(when (and openwith-mode (not (buffer-modified-p)) (zerop (buffer-size)))
|
|
||||||
(let ((assocs openwith-associations)
|
|
||||||
(file (car args))
|
|
||||||
oa)
|
|
||||||
;; do not use `dolist' here, since some packages (like cl)
|
|
||||||
;; temporarily unbind it
|
|
||||||
(while assocs
|
|
||||||
(setq oa (car assocs)
|
|
||||||
assocs (cdr assocs))
|
|
||||||
(when (save-match-data (string-match (car oa) file))
|
|
||||||
(let ((params (mapcar (lambda (x) (if (eq x 'file) file x))
|
|
||||||
(nth 2 oa))))
|
|
||||||
(when (or (not openwith-confirm-invocation)
|
|
||||||
(y-or-n-p (format "%s %s? " (cadr oa)
|
|
||||||
(mapconcat #'identity params " "))))
|
|
||||||
(apply #'start-process "openwith-process" nil (cadr oa) params)
|
|
||||||
(kill-buffer nil)
|
|
||||||
;; inhibit actions that would follow the regular
|
|
||||||
;; insertion of file contents
|
|
||||||
(let (debug-on-error)
|
|
||||||
(error "Opened %s in external program"
|
|
||||||
(file-name-nondirectory file)))))))))
|
|
||||||
;; when no association was found, relay the operation to other handlers
|
|
||||||
(let ((inhibit-file-name-handlers
|
|
||||||
(cons 'openwith-file-handler
|
|
||||||
(and (eq inhibit-file-name-operation operation)
|
|
||||||
inhibit-file-name-handlers)))
|
|
||||||
(inhibit-file-name-operation operation))
|
|
||||||
(apply operation args)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(define-minor-mode openwith-mode
|
|
||||||
"Automatically open files with external programs."
|
|
||||||
:lighter ""
|
|
||||||
:global t
|
|
||||||
(if openwith-mode
|
|
||||||
(progn
|
|
||||||
;; register `openwith-file-handler' for all files
|
|
||||||
(put 'openwith-file-handler 'safe-magic t)
|
|
||||||
(put 'openwith-file-handler 'operations '(insert-file-contents))
|
|
||||||
(add-to-list 'file-name-handler-alist '("" . openwith-file-handler)))
|
|
||||||
(setq file-name-handler-alist
|
|
||||||
(delete '("" . openwith-file-handler) file-name-handler-alist))))
|
|
||||||
|
|
||||||
(provide 'openwith)
|
|
||||||
|
|
||||||
;;; openwith.el ends here
|
|
Loading…
Add table
Add a link
Reference in a new issue