Add prelude-github
Conflicts: core/prelude-core.el
This commit is contained in:
parent
754451a34a
commit
c0727a8404
3 changed files with 29 additions and 19 deletions
|
@ -218,6 +218,7 @@ Keybinding | Description
|
||||||
-------------------|------------------------------------------------------------
|
-------------------|------------------------------------------------------------
|
||||||
<kbd>C-c o</kbd> | Open the currently visited file with an external program.
|
<kbd>C-c o</kbd> | Open the currently visited file with an external program.
|
||||||
<kbd>C-c g</kbd> | Search in Google for the thing under point (or an interactive query).
|
<kbd>C-c g</kbd> | Search in Google for the thing under point (or an interactive query).
|
||||||
|
<kbd>C-c G</kbd> | Search in GitHub for the thing under point (or an interactive query).
|
||||||
<kbd>C-c y</kbd> | Search in YouTube for the thing under point (or an interactive query).
|
<kbd>C-c y</kbd> | Search in YouTube for the thing under point (or an interactive query).
|
||||||
<kbd>C-S-RET</kbd> or <kbd>M-o</kbd> | Insert an empty line above the current line and indent it properly
|
<kbd>C-S-RET</kbd> or <kbd>M-o</kbd> | Insert an empty line above the current line and indent it properly
|
||||||
<kbd>S-RET</kbd> or <kbd>M-O</kbd> | Insert an empty line and indent it properly (as in most IDEs).
|
<kbd>S-RET</kbd> or <kbd>M-O</kbd> | Insert an empty line and indent it properly (as in most IDEs).
|
||||||
|
|
|
@ -43,11 +43,11 @@ With a prefix ARG always prompt for command to use."
|
||||||
(when buffer-file-name
|
(when buffer-file-name
|
||||||
(start-process "prelude-open-with-process"
|
(start-process "prelude-open-with-process"
|
||||||
"*prelude-open-with-output*"
|
"*prelude-open-with-output*"
|
||||||
(cond
|
(cond
|
||||||
((and (not arg) (eq system-type 'darwin)) "open")
|
((and (not arg) (eq system-type 'darwin)) "open")
|
||||||
((and (not arg) (member system-type '(gnu gnu/linux gnu/kfreebsd))) "xdg-open")
|
((and (not arg) (member system-type '(gnu gnu/linux gnu/kfreebsd))) "xdg-open")
|
||||||
(t (read-shell-command "Open current file with: ")))
|
(t (read-shell-command "Open current file with: ")))
|
||||||
(shell-quote-argument buffer-file-name))))
|
(shell-quote-argument buffer-file-name))))
|
||||||
|
|
||||||
(defun prelude-buffer-mode (buffer-or-name)
|
(defun prelude-buffer-mode (buffer-or-name)
|
||||||
"Retrieve the `major-mode' of BUFFER-OR-NAME."
|
"Retrieve the `major-mode' of BUFFER-OR-NAME."
|
||||||
|
@ -61,25 +61,31 @@ With a prefix ARG always prompt for command to use."
|
||||||
(ansi-term (getenv "SHELL")))
|
(ansi-term (getenv "SHELL")))
|
||||||
"*ansi-term*"))
|
"*ansi-term*"))
|
||||||
|
|
||||||
|
(defun prelude-search (query-url prompt)
|
||||||
|
"Open the search url constructed with the QUERY-URL.
|
||||||
|
PROMPT sets the `read-string prompt."
|
||||||
|
(browse-url
|
||||||
|
(concat query-url
|
||||||
|
(url-hexify-string
|
||||||
|
(if mark-active
|
||||||
|
(buffer-substring (region-beginning) (region-end))
|
||||||
|
(read-string prompt))))))
|
||||||
|
|
||||||
(defun prelude-google ()
|
(defun prelude-google ()
|
||||||
"Googles a query or region if any."
|
"Googles a query or region if any."
|
||||||
(interactive)
|
(interactive)
|
||||||
(browse-url
|
(prelude-search "http://www.google.com/search?q=" "Google: "))
|
||||||
(concat
|
|
||||||
"http://www.google.com/search?ie=utf-8&oe=utf-8&q="
|
|
||||||
(url-hexify-string (if mark-active
|
|
||||||
(buffer-substring (region-beginning) (region-end))
|
|
||||||
(read-string "Google: "))))))
|
|
||||||
|
|
||||||
(defun prelude-youtube ()
|
(defun prelude-youtube ()
|
||||||
"Search YouTube with a query or region if any."
|
"Search YouTube with a query or region if any."
|
||||||
(interactive)
|
(interactive)
|
||||||
(browse-url
|
(prelude-search "http://www.youtube.com/results?search_query="
|
||||||
(concat
|
"Search YouTube: "))
|
||||||
"http://www.youtube.com/results?search_query="
|
|
||||||
(url-hexify-string (if mark-active
|
(defun prelude-github ()
|
||||||
(buffer-substring (region-beginning) (region-end))
|
"Search GitHub with a query or region if any."
|
||||||
(read-string "Search YouTube: "))))))
|
(interactive)
|
||||||
|
(prelude-search "https://github.com/search?q=" "Search GitHub: "))
|
||||||
|
|
||||||
(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg)
|
(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg)
|
||||||
"Indent region between BEGIN and END by ARG columns and copy to clipboard."
|
"Indent region between BEGIN and END by ARG columns and copy to clipboard."
|
||||||
|
@ -416,6 +422,8 @@ Doesn't mess with special buffers."
|
||||||
"Press <jl> quickly to jump to a visible line."
|
"Press <jl> quickly to jump to a visible line."
|
||||||
"Press <C-c h> to navigate a project in Helm."
|
"Press <C-c h> to navigate a project in Helm."
|
||||||
"Press <C-c g> to search in Google."
|
"Press <C-c g> to search in Google."
|
||||||
|
"Press <C-c G> to search in GitHub."
|
||||||
|
"Press <C-c y> to search in YouTube."
|
||||||
"Press <C-c r> to rename the current buffer and file it's visiting."
|
"Press <C-c r> to rename the current buffer and file it's visiting."
|
||||||
"Press <C-c t> to open a terminal in Emacs."
|
"Press <C-c t> to open a terminal in Emacs."
|
||||||
"Press <C-c k> to kill all the buffers, but the active one."
|
"Press <C-c k> to kill all the buffers, but the active one."
|
||||||
|
@ -490,7 +498,7 @@ Doesn't mess with special buffers."
|
||||||
(error "No integer here"))
|
(error "No integer here"))
|
||||||
;; Skip backward over optional sign
|
;; Skip backward over optional sign
|
||||||
(when (looking-back "[+-]")
|
(when (looking-back "[+-]")
|
||||||
(backward-char 1))))
|
(backward-char 1))))
|
||||||
(put 'integer 'beginning-op 'thing-at-point-goto-beginning-of-integer)
|
(put 'integer 'beginning-op 'thing-at-point-goto-beginning-of-integer)
|
||||||
|
|
||||||
(defun thing-at-point-bounds-of-integer-at-point ()
|
(defun thing-at-point-bounds-of-integer-at-point ()
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map (kbd "C-c o") 'prelude-open-with)
|
(define-key map (kbd "C-c o") 'prelude-open-with)
|
||||||
(define-key map (kbd "C-c g") 'prelude-google)
|
(define-key map (kbd "C-c g") 'prelude-google)
|
||||||
|
(define-key map (kbd "C-c G") 'prelude-github)
|
||||||
(define-key map (kbd "C-c y") 'prelude-youtube)
|
(define-key map (kbd "C-c y") 'prelude-youtube)
|
||||||
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
|
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
|
||||||
(define-key map [(shift return)] 'prelude-smart-open-line)
|
(define-key map [(shift return)] 'prelude-smart-open-line)
|
||||||
|
@ -118,7 +119,7 @@
|
||||||
["View URL" prelude-view-url]))
|
["View URL" prelude-view-url]))
|
||||||
"Search Files (Grep)...")
|
"Search Files (Grep)...")
|
||||||
|
|
||||||
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
|
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
|
||||||
|
|
||||||
(defun prelude-mode-remove-menu ()
|
(defun prelude-mode-remove-menu ()
|
||||||
"Remove `prelude-mode' menu entry."
|
"Remove `prelude-mode' menu entry."
|
||||||
|
|
Loading…
Reference in a new issue