Skip to content

Instantly share code, notes, and snippets.

@ftrain
Last active July 16, 2021 17:26
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ftrain/8443721 to your computer and use it in GitHub Desktop.
Save ftrain/8443721 to your computer and use it in GitHub Desktop.
a nice .emacs for when you are on a terminal. Respects scroll wheel events. Very useful when run inside of tmux and combined with this tmuxconf: https://gist.github.com/ftrain/8443744
;; .emacs
;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)
;; enable visual feedback on selections
(setq transient-mark-mode t)
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" (system-name)))
;; default to unified diffs
(setq diff-switches "-u")
;; always end a file with a newline
;(setq require-final-newline 'query)
;;; uncomment for CJK utf-8 support for non-Asian users
;; (require 'un-define)
(require 'xt-mouse)
(xterm-mouse-mode)
(require 'mouse)
(xterm-mouse-mode t)
(defun track-mouse (e))
(setq mouse-wheel-follow-mouse 't)
(defvar alternating-scroll-down-next t)
(defvar alternating-scroll-up-next t)
(defun alternating-scroll-down-line ()
(interactive "@")
(when alternating-scroll-down-next
; (run-hook-with-args 'window-scroll-functions )
(scroll-down-line))
(setq alternating-scroll-down-next (not alternating-scroll-down-next)))
(defun alternating-scroll-up-line ()
(interactive "@")
(when alternating-scroll-up-next
; (run-hook-with-args 'window-scroll-functions)
(scroll-up-line))
(setq alternating-scroll-up-next (not alternating-scroll-up-next)))
(global-set-key (kbd "<mouse-4>") 'alternating-scroll-down-line)
(global-set-key (kbd "<mouse-5>") 'alternating-scroll-up-line)
;; Compile to JS on every save.
(add-hook 'after-save-hook
'(lambda ()
(when (string-match "\\.coffee$" buffer-file-name)
(coffee-compile-file))))
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
;(elpy-enable)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
@louwers
Copy link

louwers commented Feb 3, 2016

Any ideas on how to get real-time visual selection feedback, which vim has?

@roelandmoors
Copy link

I use cua mode. With C-RET you can start a visual selection. (=cua-set-rectangle-mark)

@PythonNut
Copy link

@louwers, do you mean for mouse-drag selection?

@FredJiang
Copy link

FredJiang commented May 12, 2017

Thank you, it saved my time. And how to scroll quickly if I have a file with many lines like more than 1000 lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment