Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rosslagerwall/emacsd
base: da2d2288ab
...
head fork: rosslagerwall/emacsd
compare: d1e420e456
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 18, 2012
@rosslagerwall Disable <RET> hooked onto newline-and-indent behavior 4792bbe
@rosslagerwall Add shortcut keys to change space/tab behavior and width 53f119e
@rosslagerwall Disable dtrt-indent mode.
The manual (but hopefully more reliable) alternative is emacs-24 and
shortcut keys for easily changing spaces/tabs and widths.
d1e420e
Showing with 41 additions and 12 deletions.
  1. +38 −8 bindings.el
  2. +3 −4 init.el
View
46 bindings.el
@@ -8,20 +8,20 @@
(global-set-key (kbd "<f10>") 'compile)
;; enter is newline & indent for c mode
-(add-hook 'c-mode-common-hook '(lambda ()
- (local-set-key (kbd "RET") 'newline-and-indent)))
+;;(add-hook 'c-mode-common-hook '(lambda ()
+;; (local-set-key (kbd "RET") 'newline-and-indent)))
;; enter is newline
-(add-hook 'c-mode-common-hook '(lambda ()
- (local-set-key (kbd "C-j") 'newline)))
+;;(add-hook 'c-mode-common-hook '(lambda ()
+;; (local-set-key (kbd "C-j") 'newline)))
;; enter is newline & indent for python mode
-(add-hook 'python-mode-hook '(lambda ()
- (local-set-key (kbd "RET") 'newline-and-indent)))
+;;(add-hook 'python-mode-hook '(lambda ()
+;; (local-set-key (kbd "RET") 'newline-and-indent)))
;; enter is newline
-(add-hook 'python-mode-hook '(lambda ()
- (local-set-key (kbd "C-j") 'newline)))
+;;(add-hook 'python-mode-hook '(lambda ()
+;; (local-set-key (kbd "C-j") 'newline)))
;; move to mark with F9
(defun jump-to-mark ()
@@ -48,4 +48,34 @@ This is the same as using \\[set-mark-command] with the prefix argument."
;; Other window with F8
(global-set-key (kbd "<f8>") 'other-window)
+;; toggle indentation level
+;; http://stackoverflow.com/questions/530461/emacs-lisp-function-to-toggle-variable-tab-width-between-4-8
+(global-set-key (kbd "<f5>") 'tf-toggle-tab-width-setting)
+(defun tf-toggle-tab-width-setting ()
+ "Toggle setting tab widths between 4 and 8"
+ (interactive)
+ (setq c-basic-offset (if (= c-basic-offset 8) 4 8))
+ (message "set c-basic-offset to %d." c-basic-offset)
+ (redraw-display))
+
+;; toggle tabs or spaces
+;; http://stackoverflow.com/questions/530461/emacs-lisp-function-to-toggle-variable-tab-width-between-4-8
+(global-set-key (kbd "<f6>") 'tf-toggle-tab-mode-setting)
+(defun tf-toggle-tab-mode-setting ()
+ "Toggle setting tab or spaces"
+ (interactive)
+ (setq indent-tabs-mode (if (eq indent-tabs-mode t) nil t))
+ (message "Indenting using %s." (if (eq indent-tabs-mode t) "tabs" "spaces"))
+ (redraw-display))
+
+;; toggle tab indentation level
+;; http://stackoverflow.com/questions/530461/emacs-lisp-function-to-toggle-variable-tab-width-between-4-8
+(global-set-key (kbd "<f4>") 'tf-toggle-actual-tab-width-setting)
+(defun tf-toggle-actual-tab-width-setting ()
+ "Toggle setting actual tab widths between 4 and 8"
+ (interactive)
+ (setq tab-width (if (= tab-width 8) 4 8))
+ (message "set tab-width to %d." tab-width)
+ (redraw-display))
+
(provide 'bindings)
View
7 init.el
@@ -1,7 +1,7 @@
;; .emacs
;; set up load path
- (add-to-list 'load-path "~/.emacs.d")
+(add-to-list 'load-path "~/.emacs.d")
;; prefer UTF-8 coding system
(setq prefer-coding-system 'utf-8)
@@ -19,8 +19,8 @@
c-basic-offset 4)
;; not needed with emacs 24 and cc-guess (needed to guess between tabs and spaces)
;; use dtrt to automatically use the correct tab/indenting style
-(require 'dtrt-indent)
-(dtrt-indent-mode 1)
+;;(require 'dtrt-indent)
+;;(dtrt-indent-mode 1)
;; make "yes or no" "y or n"
(fset 'yes-or-no-p 'y-or-n-p)
@@ -29,7 +29,6 @@
(setq backup-directory-alist
`(("." . ,(expand-file-name "~/.emacs.d/_backups"))))
-
;; make the font a bit bigger
(set-face-attribute 'default nil :height 110)

No commit comments for this range

Something went wrong with that request. Please try again.