Movement in Emacs using a Space-Modifier - emacs

Setup: I am running a fairly vanilla version of Emacs Prelude after I quit using Spacemacs some days ago (mainly because the usual evil-mode-incompatibities were grinding my gears).
Problem: I am having issues with the Emacs' movement commands, in particular because I am already getting a bit of an 'Emacs Pinky'. My current workaround is using modalka-mode with h/j/k/l bindings. What I would love is a direct mapping of <SPC>-h/j/k/l to the corresponding Emacs commands C-b/n/p/f. This would require the space-key to be some sort of modifier when held down. Is my desired behavior achievable in Emacs, and if yes, how?
Remark: I do not want to use evil-mode, since I found the incompatibilities with other packages to be overly annoying.

If I understand your question correctly you are looking for mode called "space-chord".
It is installable with melpa or here:
https://www.emacswiki.org/emacs/space-chord.el
You might want to look into key chords also:
https://www.emacswiki.org/emacs/KeyChord
They are awesome, especially with evil mode. For example I have "jk" bound to normal mode instead of escape or C-[.

Related

Emacs Minor Mode Sticky Control

Is there a minor mode in emacs that attaches a Control Key to every keystroke representing a single character? I wanted to get something similar to action mode in Vim. I've seen Viper, but would prefer not to spend the time to relearn all of the key-bindings.
Take a look at https://github.com/chrisdone/god-mode
This is a global minor mode for entering Emacs commands without modifier keys. It's similar to Vim's separation of commands and insertion mode.
The difference between this and viper/vimpulse/evil is that god-mode is still using the standard Emacs bindings.
It's not a direct answer1 to your question, but I think it implements your actual end goal.
1 This might be of some interest: Software Requirements for Code Creation / Editor with RSI Type Symptoms (unusable fingers)

How to redefine Fortran comment character for Emacs?

I am coding in fortran90 on Emacs (no-windows mode) with fortran-mode. I have only used Emacs for Python for which it works without problem but now that I have switched to fortran90 I have many little issues that I don't know how to configure.
The biggest problem I have is with the commenting region command. I usually use M-; to comment regions but I get something like this:
c$$$ if (x1.eq.0) then
I know about the command
C-x r t
which actually does the trick (I can insert a ! at the beginning of each line) but I am so used to the M-; command and I wish I could keep using it. Also, with the latter command I can comment and un-comment the region.
So what I want to do is to replace the symbol for commenting in (and only in) fortran-mode. And such that it works every time I open/close Emacs with fortran-mode.
Thanks!
I haven't coded in Fortran for the last 30 years (!), and I'm not acquainted with Fortran mode in Emacs. But looking at library fortran.el I see that there are some user options for customizing comment behavior. Take a look at them by using M-x customize-group fortran-comment. The doc for each should be self-explanatory. If not, more info is available in the Emacs manual -- see node Fortran and its subnodes, in particular, node Fortran Comments. It specifically talks about M-; in the context of Fortran mode, for instance.

Emacs Prelude, Smartparens, and OsX

I'm using OSX 10.9, iTerm2, Emacs Prelude, and Clojure with all the modes that entails most relevantly, smartparens. Good so far.
The short version is: has anybody out there found a harmonious way to use all of this together with OSX Mission Control?
The longer version goes: I want to be able to use commands like sp-forward-slurp-sexp, which has a default keybinding of C-<right>, better known as the default OS-level shortcut for "switch Spaces right via Mission Control." I can re-map that fairly easily (say, to C-Shift-<right>) -- but now, I discover that C-<right> actually seems to be sending something like M-[1;4A. Instead of triggering sp-forward-slurp-sexp, you get sp-wrap-with-pair "[". Uhm.
I dug up this dissertation on re-mapping keys, which is very thorough, but also involves re-mapping rather a deal of stuff, then disabling the parts of paredit that are listening for the M-[ command. While this technically seems to work, I actually rather like having sp-wrap-with-pair enabled. Perhaps a better option would be to embrace the theoretically equivalent C-( -- except iTerm2 only interprets that as a literal 9, and C-) as 0. This SO post chews on this problem, and gets as far as a tantalizing comment suggesting that C-( and C-) simply be re-mapped to escape sequences that emacs can map back to C-( and C-) -- but frankly, I haven't a clue how to figure out what escape sequences those should be.
Bringing it all home: has anybody found a way to use all of these tools (Mission Control, iTerm2, Emacs Prelude, smartparens) together without having to re-wire or disable parts of some or most of them? Or: who has the most elegant re-wiring? Anybody figured out the C-)-to-escape-sequence-back-to-C-) trick yet?
Edit
Stabbing in the dark, I've done the following:
1. Set iTerm to send an escape sequence for the keyboard shortcut Ctrl-Shift-0 (C-S-)) of SPRTPRN.
2. Put this in my emacs config:
(define-key input-decode-map "\eSPRTPRN" [C-right-paren])
(global-set-key [C-right-paren] (kbd "C-)"))
...it does not work, but I've a hunch I'm getting closer. I think.
Edit, Again
I realized something: the notion that Shift doesn't work here doesn't make sense to me. At least on my emacs install, M-< and M-> jump to the beginning and end of a buffer, respectively -- and to use those commands, I have to actually press Meta-Shift-<. Huh.

Code folding in Emacs [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to achieve code folding effects in emacs
An excellent feature of Dreamweaver is code folding of any lines of text -- recursively!
It's fantastic, I can fold any text or code, regardless of language. I work with existing systems; I don't edit well-written code or code in one language etc. mostly HTML mixed with god-knows-what. Folding lines makes understanding a lot easier and quicker. Sadly, this is the only feature I like in Dreamweaver.
Is there any code folding for Emacs in a similar aim?
There's folding mode, a minor mode. Unfortunately it's intrusive: you have to manually annotate the folds with specialized comments, which clutter the code when you aren't using the mode (or when sharing code with others who don't use it). A better mode would not change your code to work.
Let me add: there's a duplicate of this that's worth a look: How to achieve code folding effects in Emacs.
hide-show (hs-minor-mode) is a minor mode that will do something like this...
The default key-binding to trigger the folding is C-c # C-c which I find pretty cumbersome. But then I don't use it much, either.
You might want to look up the function set-selective-display and the variable selective-display. Not exactly what you want but it lets you hide lines based on indentation level.
I use fold-dwim.el. From the emacs wiki:
fold-dwim.el is a unified user interface for Emacs folding/outlining modes. It supports folding.el, hideshow.el, outline.el, TeX-fold.el, and nxml-outln.el
You can get it here:
http://www.emacswiki.org/emacs/FoldDwim
I have this in my .emacs:
(require 'fold-dwim)
(global-set-key [(C kp-4)] 'fold-dwim-hide-all)
(global-set-key [(C kp-5)] 'fold-dwim-toggle)
(global-set-key [(C kp-6)] 'fold-dwim-show-all)
Keep in mind that you still need to activate hs-minor-mode, folding-mode, etc. but I find it easier to use them this way.
Something else you might look into is nxhtml-mode; it doesn't fold code, but it does highlight mixed code (i.e. HTML and PHP) differently depending on its type. That gives you a similar gain in comprehensibility without the awkwardness of folding-mode. I think that approach is more suited to Emacs anyway, first because code-folding seems like a mouse-oriented idea that doesn't adapt well to the basically keyboard-centric Emacs interface, and second because Emacs eases navigating a large file to an extent that code can stay visible without getting in your way.
If you actually need "something to hide a given region rather than it trying to understand the syntax" (unlike hideshow and other solutions based on parsing) and you "don't want to have to edit [your] code" (unlike folding), then, I assume, you mean you don't want the regions to be persistent between different editing sessions. Then you might use http://www.emacswiki.org/emacs/HideRegion to hide user-selected regions...
(But that's strange. The folding minor mode with persistent marks seems to be a far more convenient solution.)

What program can help a REPL shell remember and search history?

I'm playing with Paul Graham's arc, and it's getting really annoying that the up arrow inserts ^[[A instead of the previous command, and ^R doesn't work as in shell. I vaguely remember there being a simple way to run Arc's REPL in a program which will remember the input history - does anyone know what it is?
Perhaps you're thinking of rlwrap?
I like rlwrap too, but other options include:
Emacs modes:
shell
term
comint
Slime (works with Common Lisps and Clojure, probably not with Arc)
ssfe (the frontend part of sirc)
jline (especially if the REPL is written in Java, which arc is not)
nex3's arc on github comes with a script arc.sh which calls rlwrap by default, and an emacs mode to use the history with alt+P and alt+N.