Git Product home page Git Product logo

scamx's Introduction

Scamx: A Minimalist Modal Editing Mechanism for Emacs

Scamx is an experimental modal editing mechanism designed for Emacs. It introduces a modularized, multi-layered approach that integrates seamlessly with default Emacs keybindings, avoiding modifier keys and focusing solely on essential commands. Scamx is crafted to deliver a streamlined and functional modal editing experience within the Emacs environment. As mathematical principles dictate, only mapping matters and those powerful functions are just out there.

How to Use

  • Install dependencies meow, multiple-cursors, paredit with package-install
  • Copy the files to your .emacs.d directory:
git clone https://github.com/MagiFeeney/scamx.git && mv scamx ~/.emacs.d
  • Load the package with use-package:
(use-package scamx
  :load-path "~/.emacs.d/scamx/"
  :config
  (electric-pair-mode)     ; produce balanced expressions upon selected region
  (delete-selection-mode)  ; act without delete or kill
  (multiple-cursors-mode)  ; multiple-cursors integration
  (paredit-mode))          ; better sexp support

Modes

There are four major modes: normal, X, convert, and visit, where some minor modes, such as isearch, are wrapped into them. The normal mode serves as a base for basic navigation and modes invoking. And X mode is sequence commands with a prefix "x". Convert mode "c" is bolder compared to normal mode, and visit mode "v" navigates, views and manages buffer or window.

X mode

  • x f open a file.
  • x w write file
  • x s save buffer
  • x c save and close emacs
  • x z minimize window
  • x h select whole buffer
  • x 0 delete current window
  • x 1 delete other window
  • x 2 split window vertically
  • x 3 split window horizontally
  • x o move forward to other window
  • x O move backward to other window
  • x <tab> indent region
  • x ( start macro
  • x ) end macro
  • x e call macro
  • x [ backward page
  • x ] forward page
  • x * calculator
  • x b switch to buffer
  • x l list all buffers
  • x k kill buffer
  • x i insert file
  • x j dired jump
  • x x exchange point and mark
  • x ; comment line
  • x ' comment or uncomment region
  • x SPC pop to mark command
  • x n duplicate line
  • x ESC repeat complex command
  • x . eval last sexp
  • x : eval expression
  • x = adjust text scale
  • x <mouse-1> previous buffer
  • x <mouse-3> next buffer
  • x \ copy current file path to kill ring

Convert mode

  • g back to normal mode
  • n forward paragraph
  • p backward paragraph
  • f forward word
  • b backward word
  • d kill word or delete region if selected
  • backspace backward kill word or delete region if selected
  • e forward kill sexp
  • a backward kill sexp
  • j join sexps
  • r raise sexp
  • % split sexp
  • k kill paragraph or kill region if selected
  • h mark paragraph
  • l kill whole line
  • w copy
  • y yank
  • u undo
  • / redo
  • a backward kill sexp
  • e kill sexp
  • ( backward list
  • ) forward list
  • [ backward sexp
  • ] forward sexp
  • { backward up list
  • } forward up list
  • < move beginning of defun
  • > move end of defun
  • = mark sexp
  • , mark defun
  • s allow one key in Normal mode be executed

Visit mode

  • g back to normal mode
  • l last buffer
  • n next buffer
  • p previous buffer
  • f other window
  • b previous window any frame
  • c clone buffer
  • s scratch buffer
  • d scroll page down
  • D scroll other page down
  • u scroll page up
  • U scroll other page up
  • e scroll line down
  • a scroll line up
  • r revert buffer
  • 0 balance windows
  • m minimize window
  • M maximize window
  • + bold enlarge window horizontally
  • - bold shrink window horizontally
  • w swap window
  • ( tear off window
  • ) delete frame
  • If you have installed package ace-window, then you can further have:
    • t select window

Normal mode

  • x X mode
  • c convert mode
  • v visit mode
  • ` motion mode
  • ? help mode
  • g cancel selection or exit minibuffer
  • a move beginning of line
  • e move end of line
  • d delete forward one char or delete region if selected
  • backspace delete backward one char or delete region if selected
  • i insert
  • o open below
  • O open above
  • n next line
  • p previous line
  • f forward char
  • b backward char
  • j newline (a.k.a <return>)
  • m back to indentation
  • s isearch forward minor mode
  • k kill line at point or kill region if selected
  • h mark line
  • w copy
  • y yank
  • u undo
  • / redo
  • t select to char
  • z zap to char
  • Z zap up to char
  • q quit current buffer
  • Q goto line
  • r repeat
  • l recenter top bottom
  • \ delete horizontal space
  • = mark word
  • SPC set mark command
  • ! shell command
  • $ ispell word
  • % query replace

Multiple cursors in Normal mode

  • [ mc/mark-previous-like-this
  • ] mc/mark-next-like-this
  • < mc/skip-to-previous-like-this
  • > mc/skip-to-next-like-this
  • ; mc/mark-all-dwim
  • : mc/mark-all-like-this
  • ' mc/edit-lines
  • @ mc/mark-all-words-like-this
  • # mc/mark-all-in-region

Insert mode

  • gg back to normal mode

Help mode (Distilled)

  • ? k describe key
  • ? c describe key briefly
  • ? f describe function
  • ? m describe mode
  • ? \ describe input method
  • ? b describe bindings
  • ? p describe package
  • ? t tutorial
  • ? d debugging tutorial
  • ? e view *Messages* buffer
  • ? r find manual
  • ? i info overview
  • ? s search for command
  • ? v search by keyword
  • ? C-q quick toggle
  • ? ? further options
  • ? q quit help

To view commands from X mode, you can type x followed by ?.

Minibuffer

When enter into the minibuffer, it is by default at the insert mode. Once you have finished typing, you can call gg to leave insert mode, then use the regular navigation commands such as n or p to select the candidates. If you have finished selection, you can use <return> to abort the minibuffer, or just use g to leave if it needs to be stopped.

If you want to loop through the history, you can use n or p in convert mode instead.

Visit mode also applies to the minibuffer, which means you can move back-and-forth between buffers and the minibuffer.

Isearch minor mode

Isearch forward is wrapped into an additional layer. Once it is invoked with the s key, it prompts at the minibuffer to enter the string to be searched. Hitting return then marks the finish of the input process. After that, you can use the familiar navigation commands n or p to loop through all candidate in the buffer. When s is pressed again, you can enter a new string to search. Otherwise, you can go back to the normal state with g. You can also simply leave the input string blank followed by the return. With g, you can directly leave.

Please check the full set up in scamx-anchor.el.

Mark

  • You can hit SPC twice to set mark, and then use x SPC to return back to the position.
  • The convert mode can be invoked on top of the current mark, use whatever commands needed, then revert back to normal mode while keeping the mark.

Negative argument

  • - can be combined with directional commands, i.e. - t select backward to, - h mark backward line.
  • You can then use r to repeat those commands if needed.

Issues and Plans

  • In visit mode, it may occasionally not handle the buffer *Messages* properly when navigating previous or next buffer at first attempt.
  • Command conflicts would be observed in one-key oriented mode i.e. dired-mode, image-mode and magit-mode etc.

Now you can switch between those modes and scamx, by entering into the normal mode with g and reverting back with `. When g conflicts with revert buffer, you can alternatively use r in visit mode.

TODO list

First Stage

  • Add more functions to convert mode (i.e. up-list, kill-sexp).
  • Integrate with multiple-cursors.
  • Merge meow of things command series into generalized zap command in a dwim style.
  • Allow one command in the normal mode be excuted in the convert mode (like ctrl-o in vim).

Second Stage

  • Motion mode as buffer-wise.
  • Improve selection of inside and outside of balanced expressions.

scamx's People

Contributors

magifeeney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

scamx's Issues

Symbol’s value as variable is void: visit

Description

Error Message:

Error (use-package): scamx/:catch: Symbol’s value as variable is void: visit

Environment Information

  • Operating System: Opensuse-TW/Linux
  • Emacs Version: 29.2
  • Emacs Package Manager: elpaca

Steps to Reproduce

  1. Install scamx package using the following configuration:

    (use-package scamx
      :ensure (:host github :repo "MagiFeeney/scamx")
      :config
      (electric-pair-mode))
  2. Attempt to run Emacs with the provided configuration.

Expected Behavior

The scamx package should be loaded without any errors.

Actual Behavior

The error mentioned above occurs, preventing the successful loading of the scamx package.

Additional Information

  • This issue is reproducible in the specified environment.
  • No other conflicting packages are being used.

Thank you for your assistance in resolving this issue!

C-c handling

Hello.
There doesn't seem to be a mapping for the C-c leader, are you using any yourself?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.