Realmente estoy tratando de cambiar a emacs, pero aprender a configurar el entorno es un verdadero dolor. Todo el mundo dice que vale la pena, así que simplemente continúo.Emacs indentation dificultad
Quiero que mi código C para implementar esa manera:
if(asdf)
{
asdr = 1;
}
Dependiendo del estándar actual (lo sé, no me refiero a), podría ser:
if(asdf) {
asdr = 1;
}
I parece que no puede cambiar el tamaño de sangría de 2, siempre se parece al estándar GNU:
if(asdf)
{
asdr = 1;
}
, que no me gusta. Esto es lo que he puesto en mi .emacs:
; Warn in C for while();, if(x=0), ...
(global-cwarn-mode 1)
; no electric mode in c
(c-toggle-electric-state -1)
; indent the current line only if the cursor is at the beginning of the line
(setq-default c-tab-always-indent nil)
(setq-default c-indent-level 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 4)
(setq-default c-basic-indent 4)
; These commands I read about on the web, but they don't work?
;(highlight-tabs)
;(highlight-trailing_whitespace)
Esto no ayuda, no tengo todavía el guión de GNU. ¿Alguien?
--- Editar para añadir mi .emacs conjunto (en realidad ~/.emacs.d/init.el)
; directory to put various el files into
(add-to-list 'load-path "C:/Program/emacs-22.3/includes")
; loads ruby mode when a .rb file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".rhtml$" . html-mode) auto-mode-alist))
(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
)))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(define-key ruby-mode-map "\C-m" 'newline-and-indent) ;Not sure if this line is 100% right but it works!
(require 'ruby-electric)
(ruby-electric-mode t)
))
; Install mode-compile to give friendlier compiling support!
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
(show-paren-mode 1)
; Color theme
(require 'color-theme)
(color-theme-pok-wog)
;;Emacs.pane.menubar.* does not seem to work?
;Emacs.pane.menubar.background: darkGrey
;Emacs.pane.menubar.foreground: black
; Default font 9 pt
(set-face-attribute 'default nil :height 80)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(font-lock-comment-face ((t (:foreground "limegreen" :slant oblique))))
'(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "orange" :weight bold)))))
(global-set-key [C-tab] 'other-window)
(global-set-key [C-S-tab] (lambda() (interactive) (other-window -1)))
(defun linux-c-mode()
"C mode with adjusted defaults for use with the Linux
kernel."
(interactive)
(c-mode)
(setq c-indent-level 8)
(setq c-brace-imaginary-offset 0)
(setq c-brace-offset -8)
(setq c-argdecl-indent 8)
(setq c-label-offset -8)
(setq c-continued-statement-offset 8)
(setq indent-tabs-mode nil)
(setq tab-width 8))
; Warn in C for while();, if(x=0), ...
(global-cwarn-mode 1)
; no electric mode in c
(c-toggle-electric-state -1)
; indent the current line only if the cursor is at the beginning of the line
(setq-default c-tab-always-indent nil)
(setq-default c-indent-level 4)
(setq-default tab-width 4)
(setq indent-tabs-mode nil)
(setq-default c-basic-offset 4)
(setq-default c-basic-indent 4)
; These commands I read about on the web, but they don't work?
;(highlight-tabs)
;(highlight-trailing_whitespace)
(setq indent-tabs-mode nil)
(setq c-default-style "user")
;; Remove lull: scroll bar, tool bar, menu bar.
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
;; restore window size as it was at previous use
(defun restore-saved-window-size()
(unless (load "~/.emacs.d/whsettings" t nil t)
(setq saved-window-size '(80 30)))
(nconc default-frame-alist `((width . ,(car saved-window-size))
(height . ,(cadr saved-window-size)))))
(restore-saved-window-size)
(defun save-window-size-if-changed (&optional unused)
(let ((original-window-size `(,(frame-width) ,(frame-height))))
(unless (equal original-window-size saved-window-size)
(with-temp-buffer
(setq saved-window-size original-window-size)
(insert (concat "(setq saved-window-size '"
(prin1-to-string saved-window-size) ")"))
(write-file "~/.emacs.d/whsettings")))))
(add-hook 'window-size-change-functions 'save-window-size-if-changed)
;; Ack as a replacment for grep
(global-set-key "\M-s" 'ack)
(require 'ack)
Me trataron de insertar la línea que escribió y la carga de archivos, pero todavía ver el estándar de GNU. También probé con "stroustrup" y "python", no hay diferencia. – Gauthier
¿Tiene un archivo de personalización que se está cargando y anulando su configuración? Además, no estoy seguro sobre el uso de setq-default con las variables de estilo de usuario. ¿Puedes probar plain setq? (Eso no explica por qué stroustrup/python no funcionaría, sin embargo). – Doug
No lo creo. Agregué mi .emacs completo en la publicación original, creo que podría ser útil. Con "usuario" casi obtengo lo que quiero. Las pestañas no se reemplazan por espacios, no entiendo por qué. – Gauthier