资源算法crux

crux

2019-12-30 | |  34 |   0 |   0

crux

A Collection of Ridiculously Useful eXtensions for Emacs. crux bundles a few useful interactive commands to enhance your overall Emacs experience.

Installation

Available on all major package.el community maintained repos -MELPA Stable and MELPA repos.

MELPA Stable is recommended as it has the latest stable version. MELPA has a development snapshot for users who don't mind breakage but don't want to run from a git checkout.

You can install crux using the following command:

M-x package-install [RET] crux [RET]

or if you'd rather keep it in your dotfiles:

(unless (package-installed-p 'crux)
  (package-refresh-contents)
  (package-install 'crux))

If the installation doesn't work try refreshing the package list:

M-x package-refresh-contents

Keybindings

crux doesn't setup any keybindings for its commands out-of-the-box.

Here's the list of some suggested keybindings. Feel free to bind individual commands to whatever keybindings you prefer.

CommandSuggested Keybinding(s)Description
crux-open-withC-c oOpen the currently visited file with an external program.
crux-smart-kill-lineC-korSuper-kFirst kill to end of line, then kill the whole line.
crux-smart-open-line-aboveC-S-RETorSuper-oInsert an empty line above the current line and indent it properly.
crux-smart-open-lineS-RETorM-oInsert an empty line and indent it properly (as in most IDEs).
crux-cleanup-buffer-or-regionC-c nFix indentation in buffer and strip whitespace.
crux-recentf-find-fileC-c forSuper-rOpen recently visited file.
crux-view-urlC-c uOpen a new buffer containing the contents of URL.
crux-eval-and-replaceC-c eEval a bit of Emacs Lisp code and replace it with its result.
crux-transpose-windowsC-x 4 tTranspose the buffers between two windows.
crux-delete-file-and-bufferC-c DDelete current file and buffer.
crux-copy-file-preserve-attributesC-c cCopy current file with file attributes preserved
crux-duplicate-current-line-or-regionC-c dDuplicate the current line (or region).
crux-duplicate-and-comment-current-line-or-regionC-c M-dDuplicate and comment the current line (or region).
crux-rename-file-and-bufferC-c rRename the current buffer and its visiting file if any.
crux-visit-term-bufferC-c tOpen a terminal emulator (ansi-term).
crux-kill-other-buffersC-c kKill all open buffers except the one you're currently in.
crux-indent-defunC-M zIndent the definition at point.
crux-indent-rigidly-and-copy-to-clipboardC-c TABIndent and copy region to clipboard
crux-find-user-init-fileC-c IOpen user's init file.
crux-find-user-custom-fileC-c ,Open user's custom file.
crux-find-shell-init-fileC-c SOpen shell's init file.
crux-top-join-lineSuper-jorC-^Join lines
crux-kill-whole-lineSuper-kKill whole line
crux-kill-line-backwardsC-BackspaceKill line backwards
crux-ispell-word-then-abbrevC-c iFix word using ispell and then save to abbrev.
crux-upcase-regionC-x C-uupcase-region when transient-mark-mode is on and region is active.
crux-downcase-regionC-x C-ldowncase-region when transient-mark-mode is on and region is active.
crux-capitalize-regionC-x M-ccapitalize-region when transient-mark-mode is on and region is active.

Here's how you'd bind some of the commands to keycombos:

(global-set-key [remap move-beginning-of-line] #'crux-move-beginning-of-line)
(global-set-key (kbd "C-c o") #'crux-open-with)
(global-set-key [(shift return)] #'crux-smart-open-line)
(global-set-key (kbd "s-r") #'crux-recentf-find-file)
(global-set-key (kbd "C-<backspace>") #'crux-kill-line-backwards)
(global-set-key [remap kill-whole-line] #'crux-kill-whole-line)

For crux-ispell-word-then-abbrev to be most effective you'll also need to add this to your config:

(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)

Origins of crux

Many of the functions in crux started life as blog posts onEmacs Redux, then were included inprelude, before finally being extractedto crux. You can see a full list of blog posts on functions in crux on the tags page.

Using the bundled advices

crux ships with some handy advises that can enhance the operation of existing commands.

(crux-with-region-or-buffer)

You can use crux-with-region-or-buffer to make a command acting normally on a region to operate on the entire buffer in the absence of a region. Here are a few examples you can stuff in your config:

(crux-with-region-or-buffer indent-region)
(crux-with-region-or-buffer untabify)

(crux-with-region-or-line)

Likewise, you can use crux-with-region-or-line to make a command alternately act on the current line if the mark is not active:

(crux-with-region-or-line comment-or-uncomment-region)

(crux-with-region-or-point-to-eol)

Sometimes you might want to act on the point until the end of the current line, rather than the whole line, in the absence of a region:

(crux-with-region-or-point-to-eol kill-ring-save)

Minor modes

(crux-reopen-as-root-mode)

Crux provides a crux-reopen-as-root command for reopening a file as root. This global minor mode changes find-file so all root files are automatically opened as root.

License

Copyright © 2015 Bozhidar Batsov and contributors.

Distributed under the GNU General Public License; typeC-h C-cto view it.


上一篇:turicreate-colab

下一篇:crux-cookbook

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...