Skip to content

Commit

Permalink
Use an alist for identifying the highlighting to be used online by us…
Browse files Browse the repository at this point in the history
…ing the active modes, for those times where you have oddly named files without an extension (eg. ~/.conkerorrc or ~/.bashrc)
  • Loading branch information
wfarr committed Aug 27, 2008
1 parent b832fb3 commit 2c15870
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion gist.el
Expand Up @@ -9,13 +9,46 @@

;; Ideas: fork

(defvar gist-supported-modes-alist '((action-script-mode . "as")
(c-mode . "c")
(c++-mode . "cpp")
(common-lisp-mode . "el")
(css-mode . "css")
(diff-mode . "diff")
(emacs-lisp-mode . "el")
(erlang-mode . "erl")
(haskell-mode . "hs")
(html-mode . "html")
(io-mode . "io")
(java-mode . "java")
(javascript-mode . "js")
(jde-mode . "java")
(js2-mode . "js")
(lua-mode . "lua")
(ocaml-mode . "ml")
(objective-c-mode . "m")
(perl-mode "pl")
(php-mode . "php")
(python-mode . "sc")
(ruby-mode . "rbx")
(text-mode . "txt")
(sql-mode . "sql")
(scheme-mode . "scm")
(smalltalk-mode . "st")
(sh-mode . "sh")
(tcl-mode . "tcl")
(tex-mode . "tex")
(xml-mode . "xml")))

(defun gist-region (begin end)
"Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring."
(interactive "r")
(let* ((file (or (buffer-file-name) (buffer-name)))
(name (file-name-nondirectory file))
(ext (or (file-name-extension file) "txt"))
(ext (or (cdr (assoc major-mode gist-supported-modes-alist))
(file-name-extension file)
"txt"))
(output (generate-new-buffer " *gist*")))
(shell-command-on-region
begin end
Expand Down

0 comments on commit 2c15870

Please sign in to comment.