• Stars
    star
    474
  • Rank 92,640 (Top 2 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created almost 13 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run command quickly. This packages is inspired quickrun.vim

melpa badge melpa stable badge

quickrun.el

Introduction

quickrun.el is Emacs port of quickrun.vim.

CI

quickrun.el is a extension to execute editing buffer. quickrun.el is similar to executable-interpret, but quickrun.el provides more convenient commands. quickrun.el execute not only script languages(Perl, Ruby, Python etc), but also compiling languages(C, C++, Go, Java etc) and markup language.

Requirements

  • Emacs 24.3 or higher.

Installation

You can install quickrun.el from MELPA with package.el.

Or install directly:

$ cd load-path-dir
$ wget https://raw.githubusercontent.com/syohex/emacs-quickrun/master/quickrun.el

After Installation add following to your configuration file(~/.emacs.d/init.el, ~/.emacs etc)

(require 'quickrun)

Support Programming Languages

quickrun.el supports following programming languages and markup languages as default. But you can register your own command and apply other languages.

Programming Language(commands used)

  • C (gcc / clang / Visual C++)
  • C++ (g++ / clang++ / Visual C++)
  • C# (dotnet / mono)
  • Objective-C (gcc -objc)
  • D Language (dmd)
  • Fortran (gfortran)
  • Java (javac / java)
  • Perl (perl)
  • Perl6 (perl6)
  • Ruby (ruby / mruby)
  • Python (python)
  • PHP (php)
  • Emacs Lisp (emacs)
  • Scheme (gosh)
  • Smalltalk (gst)
  • Racket (racket)
  • Common Lisp (clisp / sbcl / ccl)
  • Clojure (jark / clj-env-dir)
  • Javascript (node / v8 / js / jrunscript / cscript / deno)
  • Coffee Script (coffee)
  • JSX (jsx)
  • Markdown (Markdown.pl / bluecloth / kramdown / pandoc / redcarpet)
  • Haskell (runghc)
  • Go Language (go / gccgo)
  • Io (io)
  • Lua (lua)
  • Groovy (groovy)
  • Scala (scala) Please use UTF-8 encoding
  • HAML (haml)
  • SASS (sass)
  • LESS (lessc)
  • Erlang (escript)
  • OCaml (ocamlc)
  • F# (fsharpc)
  • ShellScript (shebang's shell)
  • AWK (awk)
  • Rust (rustc)
  • Dart (dart)
  • Elixir (elixir)
  • TypeScript (tsc)
  • Tcl (tclsh)
  • Swift (swift, xcrun)
  • ATS2 (patscc)
  • R (Rscript)
  • Nim/NimScript (nim)
  • Julia (julia)
  • Gnuplot (gnuplot)
  • Kotlin (kotlin)
  • Crystal (crystal)
  • V (v)
  • Applescript (osascript)
  • Assembly Language (nasm, masm)

See also quickrun--support-languages global variable.

Basic Usage

quickrun

Execute current buffer. If quickrun.el does not find command-key, then quickrun.el asks you command-key(You always input command if you use C-u prefix key)

quickrun-select

Like quickrun command but select the backend before the execution.

quickrun-region

Execute region. (Java is not supported)

quickrun-with-arg

Execute current buffer with arguments. quickrun.el asks you command line argument

quickrun-shell

Execute current buffer in eshell for interactive command such as program which reads input from STDIN.

quickrun-compile-only

Compile current buffer with compile.el framework, not execute. quickrun with C-u C-u prefix behaves same as quickrun-compile-only.

quickrun-compile-only-select

Like quickrun-compile-only command but select the backend before the execution.

quickrun-replace-region

Replace region of code with its output.

quickrun-autorun-mode

Minor mode which executes quickrun after saving buffer.

helm-quickrun

M-x quickrun with helm interface

anything-quickrun

M-x quickrun with anything interface

Note

If quickrun returns command not found, please check (executable-find "THE_COMMAND_NAME") [for example (executable-find "gnuplot")] . If this returns nil, I strongly recommend you use https://github.com/purcell/exec-path-from-shell

Send File to STDIN

If executed_file.qrinput(like foo.c.qrinput) is existed in directory same as executed buffer file, quickrun.el sends its content to stdin of executed program. Please set quickrun-input-file-extension to nil If you want to disable this feature.

Customize

quickrun-focus-p(Default: t)

If this value is nil, quickrun.el does not move focus to output buffer.

quickrun-truncate-lines(Default: t)

The truncate-lines' value for quickrun` buffer.

User Defined Command

You can add your own command or override existsing command by quickrun-add-command as below.

;; Use this parameter as C++ default
(quickrun-add-command "c++/c1z"
  '((:command . "g++")
    (:exec    . ("%c -std=c++1z %o -o %e %s"
		 "%e %a"))
    (:remove  . ("%e")))
  :default "c++")

;; Use this parameter in pod-mode
(quickrun-add-command "pod"
  '((:command . "perldoc")
    (:exec    . "%c -T -F %s"))
  :mode 'pod-mode)

;; You can override existing command
(quickrun-add-command "c/gcc"
  '((:exec . ("%c -std=c++1z %o -o %e %s"
	      "%e %a")))
  :override t)

First argument of quickrun-add-command is command key. Second argument of it is command parameter, which is described laster. quickrun-add-command also takes key parameters, :default, :mode, :override.

Argument Description
:default lang Use this command parameter as default in specified language
:mode mode this command parameter in specified mode
:override bool Override existing parameter with specified parameter

Command Parameter

Command alist has following parameters,

:command(mandatory parameter)

Command name. %c is expanded into this value.

:cmdopt(optional)

Command(:command) option. %o is expanded into this value.

:exec

Executed commands. You can also set command list parameter. If you set list parameter, quickrun.el executes command list in order.

If this parameter is omitted, quickrun.el use default execute command template "%c %o %s %a".

:timeout(optional)

Timeout in seconds for the process spawn by the command. This value takes precedence over the quickrun-timeout-seconds custom variable.

:compile-only

Command exected by quickrun-compile-only. This option is used for syntax check or converting another language(e.g. CoffeeScript => JavaScript).

:compile-conf

Configuration of quickrun-compile-only. This parameter must be alist.

:remove

Remove files after executing. If command create some intermediate files, you should set this parameter. :remove value is atom or list.

:outputter

Please see Outputter section.

:default-directory

Directory where commands are executed.

:tempfile

Use temporary file or not. quickrun.el uses temporary file if you omit this parameter.

NOTE: If you set this parameter, you cannot use quickrun-region.

:description

Description of this command. This parameter is used in helm-quickrun or anything-quickrun

Placeholders

You can use following placeholders in command parameter

Placeholder Expanded
%c Command
%o Command line option
%s Source(absolute path)
%a Script's arguments
%n Source without extension(absolute path)
%N Source without extension(nondirectory)
%d Directory name of Source(absolute path)
%e Source with executable suffix(absolute path)
%E Source with executable suffix(nondirectory)

Source file name(%s, %n etc) is not original file name except Java language. Because quickrun.el copys source file to temporary file firstly.

Change Default Command

quickrun-set-default changes default command in language that is registerd multiple command parameters(like c, c++,Javascript).

(quickrun-set-default "c" "c/clang")

This means that quickrun uses "c/clang" for C files.

Timeout Seconds

quickrun.el kills process if program run over 10 seconds as default. This avoids infinite loop program or endless program by some mistakes. You control timeout second to set quickrun-timeout-seconds. This feature is disabled if quickrun-timeout-seconds is nil. The timeout can also be set per command with the :timeout parameter. (You can also kill process by C-c C-c in quickrun buffer)

Key bindings in quickrun buffer

Key Command
q Close quickrun window
C-c C-c Kill quickrun process

Buffer Local Variables

Buffer local variables is priority to default parameters.

quickrun-option-cmd-alist

Command alist.

quickrun-option-command

Command key(Expanded to %c)

quickrun-option-cmdkey

Command key of command parameter.

quickrun-option-cmdopt

Command option(Expanded to %o)

quickrun-option-args

Program argument(Expanded to %a.)

quickrun-option-shebang

If this value is non-nil and first line of source file is started "#!", the following string is treated as ":command".

quickrun-option-outputter

Outputter function. See Outputter section

Example of buffer local variable

Setting C++11.

#include <iostream>
#include <vector>
#include <string>

int main (int argc, char *argv[])
{
    std::vector <std::string> lst = { "a", "b", "c", "d" };

    for (auto x : lst) {
        std::cout << "[" << x << "]" << std::endl;
    }

    for (auto i = 1; i < argc; i++) {
        std::cout << "[" << argv[i] << "]" << std::endl;
    }

    return 0;
}

/*
  Local Variables:
  quickrun-option-cmd-alist: ((:command . "g++")
                              (:exec    . ("%c -std=c++0x -o %n %s"
                                           "%n apple orange melon"))
                              (:remove  . ("%n")))
  End:
*/

Hooks

quickrun-after-run-hook

Run hooks after execute all commands.

Outputter

Outputter is a function for processing command output. Default outputter is to output to *quickrun* buffer and processing ANSI Color sequence.

quickrun.el defines following functions as default.

buffer:buffername

Output to buffer. outputter buffer sample

file:filename

Output to file. outputter file sample

variable:varname

Output to variable. outputter variable sample

browser

Output to Web browser(using function browse-url) outputter browser sample

message

Output to *Message* buffer(using function message) outputter message sample

multi

Use multiple outputters. outputter multi sample

null

No output. outputter null sample

Using quickrun as function from other functions

quickrun can be used as function from other functions. You can pass configuration by :source argument. Sample is following:

(defun test-perl ()
  (interactive)
  (let* ((cmd "git rev-parse --show-toplevel")
         (topdir (with-temp-buffer
                   (call-process-shell-command cmd nil t nil)
                   (goto-char (point-min))
                   (if (re-search-forward "^\\(.+\\)$" nil t)
                       (match-string 1)))))
    (quickrun :source `((:command . "prove")
                        (:default-directory . ,topdir)
                        (:exec . ("%c -bv --color %s"))))))

More Repositories

1

god-mode

Minor mode for God-like command entering
Emacs Lisp
849
star
2

git-gutter

Emacs port of GitGutter which is Sublime Text Plugin
Emacs Lisp
830
star
3

helm-swoop

Efficiently hopping squeezed lines powered by Emacs helm interface
Emacs Lisp
688
star
4

org-page

[INACTIVE] A static site generator based on Emacs and org mode.
Emacs Lisp
673
star
5

popwin

Popup Window Manager for Emacs
Emacs Lisp
496
star
6

helm-ag

The silver searcher with helm interface
Emacs Lisp
492
star
7

anzu

Emacs Port of anzu.vim
Emacs Lisp
414
star
8

emamux

tmux manipulation from Emacs
Emacs Lisp
265
star
9

ov

Overlay library for Emacs Lisp.
Emacs Lisp
211
star
10

helm-gtags

GNU GLOBAL helm interface
Emacs Lisp
204
star
11

direx

Directory Explorer for GNU Emacs
Emacs Lisp
204
star
12

terraform-mode

Major mode of Terraform configuration file
Emacs Lisp
194
star
13

git-gutter-fringe

Fringe version of git-gutter.el
Emacs Lisp
160
star
14

req-package

dependency management system on top of use-package
Emacs Lisp
153
star
15

git-messenger

Emacs Port of git-messenger.vim
Emacs Lisp
146
star
16

go-eldoc

eldoc for go language
Emacs Lisp
128
star
17

libegit2

Emacs bindings for libgit2
C
115
star
18

key-chord

Map pairs of simultaneously pressed keys to commands
Emacs Lisp
108
star
19

yascroll

Yet Another Scroll Bar Mode
Emacs Lisp
104
star
20

zoom-window

Zoom and Unzoom window
Emacs Lisp
102
star
21

company-jedi

Company backend for Python jedi
Emacs Lisp
100
star
22

swoop

Peculiar buffer navigation for Emacs
Emacs Lisp
90
star
23

org-redmine

Redmine tools using Emacs OrgMode
Emacs Lisp
83
star
24

dired-k

Highlighting dired buffer like k
Emacs Lisp
82
star
25

magit-gerrit

Magit plugin for Gerrit Code Review
Emacs Lisp
61
star
26

go-add-tags

Add field tags for struct fields
Emacs Lisp
59
star
27

pkg-info

Provide information about Emacs packages
Emacs Lisp
57
star
28

helm-css-scss

This emacs program makes your CSS/SCSS/LESS coding faster and easier than ever.
Emacs Lisp
54
star
29

smeargle

Highlighting Regions by Last Updated Time
Emacs Lisp
49
star
30

evil-anzu

anzu for Evil
Emacs Lisp
49
star
31

mongo

MongoDB driver for Emacs Lisp
Emacs Lisp
47
star
32

manage-minor-mode

Manage your minor-mode on the dedicated interface buffer. Emacs.
Emacs Lisp
47
star
33

gh-md

Render markdown using the github api
Emacs Lisp
46
star
34

farmhouse-themes

Hand-picked light and dark color theme for Emacs 24+
Emacs Lisp
43
star
35

go-direx

Tree style source code viewer for Go language
Emacs Lisp
40
star
36

undohist

Persistent Undo History for GNU Emacs
Emacs Lisp
40
star
37

helm-themes

Emacs theme selection with helm interface
Emacs Lisp
38
star
38

fontawesome

fontawesome utility
Emacs Lisp
33
star
39

go-impl

impl for Emacs
Emacs Lisp
32
star
40

ansible-doc

Ansible documentation for GNU Emacs
Emacs Lisp
32
star
41

sr-speedbar

Same frame speedbar
Emacs Lisp
31
star
42

fancy-battery

Display battery in Emacs Mode line
Emacs Lisp
31
star
43

cpp-auto-include

Insert and delete C++ header files automatically.
Emacs Lisp
31
star
44

helm-open-github

Utilities for opening github page
Emacs Lisp
29
star
45

ac-etags

etags/ctags completion source for auto-complete
Emacs Lisp
28
star
46

transpose-frame

Transpose windows arrangement in a frame
Emacs Lisp
26
star
47

osx-trash

Make Emacs' delete-by-moving-to-trash do what you expect it to do on OS X.
Emacs Lisp
26
star
48

ac-emoji

auto-complete source of Emoji
Emacs Lisp
25
star
49

ac-ispell

ispell/aspell completion source for auto-complete
Emacs Lisp
25
star
50

applescript-mode

Emacs mode for editing AppleScript
Emacs Lisp
24
star
51

codic

Codic for Emacs
Emacs Lisp
23
star
52

magit-svn

Git-Svn extension for Magit
Emacs Lisp
22
star
53

helm-pydoc

pydoc with helm interface
Emacs Lisp
20
star
54

evil-textobj-line

Evil Line text object
Emacs Lisp
18
star
55

ac-alchemist

auto-complete source of alchemist
Emacs Lisp
18
star
56

sourcemap

Sourmap parser in Emacs Lisp
Emacs Lisp
18
star
57

dart-mode

An Emacs mode for the Dart language
Dart
16
star
58

helm-ack

App::ack with helm interface
Emacs Lisp
13
star
59

helm-perldoc

perlpod with helm interface
Emacs Lisp
12
star
60

reverse-theme

Emacs color theme of reverse(like 'emacs --reverse-video')
Emacs Lisp
12
star
61

helm-github-issues

github issues with helm interface
Emacs Lisp
12
star
62

ac-capf

auto-complete source of completion-at-point
Emacs Lisp
12
star
63

sound-wav

Play wav file
Emacs Lisp
12
star
64

ac-racer

auto-complete source of racer
Emacs Lisp
10
star
65

qt-pro-mode

GNU Emacs major-mode for Qt build-system files
Emacs Lisp
9
star
66

popup-complete

Completion with popup-el
Emacs Lisp
9
star
67

splitjoin

Emacs port of splitjoin.vim
Emacs Lisp
8
star
68

miniedit

Enhanced editing for minibuffer fields
Emacs Lisp
8
star
69

helm-ispell

ispell completion with helm interface
Emacs Lisp
8
star
70

thingopt

Additional features of thingatpt.el
Emacs Lisp
8
star
71

helm-package

Listing ELPA packages with helm interface
Emacs Lisp
7
star
72

magit-p4

Magit plugin integrating git-p4 add-on.
Emacs Lisp
6
star
73

docean

Interact with DigitalOcean from Emacs
Emacs Lisp
6
star
74

pyimpsort

Sort python imports
Python
5
star
75

emamux-ruby-test

Ruby test with emamux
Emacs Lisp
5
star
76

octicons

Emacs octicons utility
Emacs Lisp
5
star
77

oberon

Major mode for editing Oberon/Oberon-2 program texts
Emacs Lisp
5
star
78

dedicated

A very simple minor mode for dedicated buffers
Emacs Lisp
4
star
79

haxe-mode

Major mode for editing Haxe files.
Emacs Lisp
4
star
80

helm-robe

Helm completing function for robe
Emacs Lisp
4
star
81

ert-expectations

The simplest unit test framework in the world
Emacs Lisp
4
star
82

keydef

A simpler way to define keys, with kbd syntax
Emacs Lisp
3
star
83

help-find-org-mode

Advise help functions to find org babel source blocks instead of tangled source
Emacs Lisp
3
star
84

test-more

Emacs Test framework like Perl's Test::More
Emacs Lisp
3
star
85

tree-mode

A mode to manage tree widgets
Emacs Lisp
3
star
86

showtip

Show tip at cursor
Emacs Lisp
3
star
87

import-popwin

Pop up buffer near by import statements with popwin
Emacs Lisp
3
star
88

literate-coffee-mode

Major mode for Literate CoffeeScript
Emacs Lisp
3
star
89

perl-utils

Emacs Perl utilities
Emacs Lisp
2
star
90

ltsv

LTSV for Emacs
Emacs Lisp
2
star
91

later-do

Execute lisp code ... later
Emacs Lisp
2
star
92

findr

Breadth-first file-finding facility for (X)Emacs
Emacs Lisp
2
star
93

org-json

Conversion between org and json
Emacs Lisp
2
star
94

dirtree

Directory tree views
Emacs Lisp
2
star
95

pylint

Minor mode for running `pylint'
Emacs Lisp
2
star
96

jedi-eldoc

Eldoc with emacs-jedi
Emacs Lisp
2
star
97

w32-browser

Run Windows application associated with a file
Emacs Lisp
2
star
98

setnu

Emacs Lisp
1
star
99

oddmuse

Edit pages on an Oddmuse wiki
Emacs Lisp
1
star
100

.github

Talk and learn about the Emacsorphanage
Makefile
1
star