Posted by : xor domingo, 17 de mayo de 2009

GNU/Emacs es un procesador de textos potentísimo que fue creado por el mismísimo Richard Stallman en 1975 junto con sus colaboradores. Está disponible para prácticamente todas las plataformas: Windows, GNU/Linux, BSD, MacOSX, Solaris, etc.



Su potencia proviene a raiz de la capacidad de personalizarlo mediante Macros, de hecho de ahí proviene su nombre Editor MACroS. Principalmente fue un editor de modo texto (obviamente en ese año otra cosa no podía ser) pero actualmente existen "forks" del proyecto en donde lo han integrado con diferentes entornos gráficos como XEmacs.

Desde hace mucho tiempo es mi editor de preferencia, lo utilizo para simplemente configurar archivos como para desarrollar código de programación en diferentes lenguajes, me resulta de lo más cómodo y no lo cambiaría por ningún otro.

Existe una "rivalidad" entre GNU/Emacs vs Vi (o Vim), al igual que sucede con GNOME vs KDE. Mi opinión es que ambos son productos que se merecen respeto por la trayectoría que arrastran. En los últimos años he notado que GNU/Emacs ha dejado de ser el editor por defecto de muchas distribuciones en favor de Vim (algunas nano u otros editores más simples), supongo que tiene que ver con el tamaño de su paquete y la línea de aprendizaje entre ambos programas, quien adopta GNU/Emacs como su procesador de textos preferido tarda un poco más de tiempo en exprimirlo al máximo.

Si aún no le diste una oportunidad a GNU/Emacs y aún no has encontrado tu "editor ideal", te sugiero lo pruebes y les des una oportunidad, al principio por ahí es una patada en los ... pero te aseguro que cuando lo tenés bien afinado es de lo más productivo en cualquier ámbito.



Con GNU/Emacs "la magia" radica en un archivo llamado .emacs que está (o estará) en el directorio home de tu usuario que es un archivo de configuración (similar al .vim) que se autoejecutará en cada sesión que abrás (como un .bashrc). La sintáxis de este archivo puede no ser muy "familiar" dado que es una versión de lenguaje Lisp, pero existen varios sitios en internet en donde te ayudan a "entenderlo":


Yo por mi parte puedo colaborar adjuntando mi propio .emacs que es producto de varios años de modificaciones y ajustes que le fuí haciendo para ir cerrando necesidades que iban surgiendo. Mi .emacs siempre lo mantuve con comentarios (como se debe) pero en lenguaje Inglés. Espero aporte algo y que tu experiencia con GNU/Emacs sea positiva.

Nando's .emacs:


;; -------------------------------------------------------------------------
;; .emacs - Nando's dot emacs
;;
;; Hernando Furlan
;; http://www.nandox.com - http://about.nandox.com
;;
;; Must create these directories first:
;;
;; ~/.emacs.semanticdb
;; ~/.emacs.backups
;;
;; -------------------------------------------------------------------------

;; Uncomment to load installed dot emacs extensions ONLY if you're Gentoo user (I was a Gentoo user that's why)
;; (load "/usr/share/emacs/site-lisp/site-gentoo")

;; My full name
(setq user-full-name "Hernando Furlan")

;; My email
(setq user-mail-address "devnando at gmail dot com")

;; My website/s
(setq user-website "http://www.nandox.com - http://about.nandox.com")

;; Save place
(require 'saveplace)
(setq-default save-place t)

;; Indent should not insert tabs
(setq-default indent-tabs-mode nil)

;; Prevent semantic.cache into entire hard disk
(setq semanticdb-default-save-directory "~/.emacs.semanticdb")

;; Autosave
(setq auto-save-default t) ; Yes auto save good!
(setq auto-save-interval 100) ; Number of input chars between auto-saves
(setq auto-save-timeout 300) ; Number of seconds idle time before auto-save

;; Backups (This saved my life a bunch of times!)
(setq make-backup-files t)
(setq backup-by-copying t) ; Don't clobber symlinks
(setq backup-directory-alist '(("." . "~/.emacs.backups"))) ; Don't litter my fs tree
(setq delete-old-versions t) ; Clean up a little
(setq kept-new-versions 6) ; Keep 6 new
(setq kept-old-versions 2) ; Keep only 2 old
(setq version-control t) ; Use versioned backups

;; Filetypes & modes
(setq auto-mode-alist
(append '(("\\.C$" . c++-mode)
("\\.cc$" . c++-mode)
("\\.cpp$" . c++-mode)
("\\.cxx$" . c++-mode)
("\\.hxx$" . c++-mode)
("\\.hpp$" . c++-mode)
("\\.h$" . c++-mode)
("\\.hh$" . c++-mode)
("\\.idl$" . c++-mode)
("\\.ipp$" . c++-mode)
("\\.c$" . c-mode)
("\\.pl$" . perl-mode)
("\\.pm$" . perl-mode)
("\\.java$" . java-mode)
("\\.inc$" . php-mode)
("\\.php$" . php-mode)
("\\.txt$" . text-mode))
auto-mode-alist))

;; I like tabs to 4 chars :P
(setq default-tab-width 4)

;; Some edition values fine-tuning
(setq c-mode-common-hook
(function (lambda ()
(setq c-basic-offset 4)
(setq c-comment-only-line-offset 0)
(setq c-indent-level 4)
(setq c-brace-imaginary-offset 0)
(setq c-brace-offset 0)
(setq c-argdecl-indent 0)
(setq c-label-offset -2)
(setq c-continued-statement-offset 0)
(setq c-continued-brace-offset -4)
(setq c-tab-always-indent t)
(setq tab-width 4)
(line-number-mode 1)
(c-set-offset 'member-init-intro 2)
(c-set-offset 'substatement-open 0)
(c-set-offset 'case-label 2)
(c-set-offset 'access-label -2)
(c-set-offset 'label 2)
(c-set-offset 'statement-case-intro 2)
(c-set-offset 'brace-list-entry 0)
(c-set-offset 'knr-argdecl-intro 0)
))
)

;; Displays name of current function in modeline
(which-function-mode)

;; Make pgup/dn remember current line
(setq scroll-preserve-screen-position t)

;; Replace "yes or no" prompt with "y or n" prompt
(defun yes-or-no-p (arg)
"Allows letters 'y' or 'n' in response to prompts asking for either 'yes' or 'no'."
(y-or-n-p arg))

;; Don't wrap long lines
(set-default 'truncate-lines t)

;; Make searches case insensitive
(setq case-fold-search t)

;;(standard-display-european +1)
(set-input-mode (car (current-input-mode))
(nth 1 (current-input-mode))
0)

;; No sounds! visual beep for me please...
(setq visible-bell t)

;; Always end a file with a newline
(setq require-final-newline t)

;; No toolbar for X (if Xemacs of course!)
(tool-bar-mode . nil)

;; No scrollbar
;; (set-scroll-bar-mode nil)

; Hide menu bar
(menu-bar-mode -1)

;; Put column number into modeline
(column-number-mode 1)

;; Display clock on global modeline
(display-time)

;; Toggle some default configuration
(custom-set-variables
'(case-fold-search t)
'(current-language-environment "English")
'(global-font-lock-mode t nil (font-lock))
'(show-paren-mode t nil (paren))
'(transient-mark-mode t)
'(uniquify-buffer-name-style nil nil (uniquify))
)

;; Customize scheme
;(set-background-color "black") ; Uncomment to avoid transparent background and get a *nice* solid colour
(set-foreground-color "white")
(set-cursor-color "white")
(set-face-foreground 'region "black")
(set-face-background 'region "white")
(set-face-foreground 'modeline "white")
(set-face-background 'modeline "red")
(set-face-foreground 'isearch "white")
(set-face-background 'isearch "red")
(set-face-background 'isearch-lazy-highlight-face "white")
(set-face-background 'isearch-lazy-highlight-face "red")

(custom-set-faces
'(region ((t (:background "red"))))
'(font-lock-comment-face ((t (:foreground "red" :weight bold))))
'(font-lock-string-face ((t (:foreground "blue" :weight bold))))
'(font-lock-keyword-face ((t (:foreground "cyan" :weight bold))))
'(font-lock-variable-name-face ((t (:foreground "cyan"))))
'(font-lock-type-face ((t (:foreground "red" :weight bold))))
'(font-lock-function-name-face ((((class color)) (:foreground "blue" :weight bold))))
'(show-paren-match-face ((((class color)) (:foreground "white" :background "red"))))
'(font-lock-constant-face ((t (:foreground "blue" :inverse-video t))))
'(font-lock-reference-face ((t (:foreground "yellow"))))
'(font-lock-preprocessor-face ((t (:foreground "yellow"))))
'(font-lock-function-name-face ((((class color) (background light)) (:foreground "yellow"))))
'(font-lock-builtin-face ((((class color) (background light)) (:foreground "yellow"))))
)

;; Code macros
(global-unset-key "\C-z") ; Turn off this key (Go emacs to background by default)
(global-unset-key "\C-t") ; Remap this key (go-top by default)

;; Replac ordinary search keys by regexp search (if you don't known regexp no problem)
(global-set-key [(control s)] 'isearch-forward-regexp)
(global-set-key [(control meta s)] 'isearch-forward)
(global-set-key [(control r)] 'isearch-backward-regexp)
(global-set-key [(control meta r)] 'isearch-backward)

;; Insert date at this point
(global-set-key "\C-t\C-d" 'insert-date-at-this-point)
(defun insert-date-at-this-point () (interactive)
(insert (format-time-string "%a %b %e, %Y %l:%M %p")))

;; Define copyright/left C style comment
(defun insert-copyleft-cstyle () (interactive)
(insert " * " projectname " - \n")
(insert " * $Id: " (file-name-nondirectory (buffer-file-name)) ",v 1.0" (format-time-string " %Y/%m/%d %H:%M:%S ") "nando Exp $\n")
(insert " *\n")
(insert " * Copyright (C)" (format-time-string " %Y ") "by Hernando Furlan \n")
(insert " * http://www.nandox.com - http://about.nandox.com\n"))

;; Define copyright/left Bash style comment
(defun insert-copyleft-bashstyle () (interactive)
(insert "# " projectname " - \n")
(insert "# $Id: " (file-name-nondirectory (buffer-file-name)) ",v 1.0" (format-time-string " %Y/%m/%d %H:%M:%S ") "nando Exp $\n")
(insert "#\n")
(insert "# Copyright (C)" (format-time-string " %Y ") "by Hernando Furlan \n")
(insert "# http://www.nandox.com - http://about.nandox.com"))

;; Define GPL license for C style comment
(defun insert-license-gpl-multifile-cstyle () (interactive)
(insert " * This file is part of " projectname ".\n")
(insert " *\n")
(insert " * " projectname " is free software; you can redistribute it and/or modify\n")
(insert " * it under the terms of the GNU General Public License as published by\n")
(insert " * the Free Software Foundation; either version 2 of the License, or\n")
(insert " * (at your option) any later version.\n")
(insert " *\n")
(insert " * " projectname " is distributed in the hope that it will be useful,\n")
(insert " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
(insert " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
(insert " * GNU General Public License for more details.\n")
(insert " *\n")
(insert " * You should have received a copy of the GNU General Public License\n")
(insert " * along with " projectname "; if not, write to the Free Software\n")
(insert " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"))

;; Define GPL license for Bash style comment
(defun insert-license-gpl-multifile-bashstyle () (interactive)
(insert "# This file is part of " projectname ".\n")
(insert "#\n")
(insert "# " projectname " is free software; you can redistribute it and/or modify\n")
(insert "# it under the terms of the GNU General Public License as published by\n")
(insert "# the Free Software Foundation; either version 2 of the License, or\n")
(insert "# (at your option) any later version.\n")
(insert "#\n")
(insert "# " projectname " is distributed in the hope that it will be useful,\n")
(insert "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
(insert "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
(insert "# GNU General Public License for more details.\n")
(insert "#\n")
(insert "# You should have received a copy of the GNU General Public License\n")
(insert "# along with " projectname "; if not, write to the Free Software\n")
(insert "# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"))

;; C/C++ file header
(global-set-key "\C-t\C-c\C-h" 'insert-c-file-header)
(defun insert-c-file-header () (interactive)
(defvar projectname (read-string "Project name? "))
(insert "/*\n")
(insert-copyleft-cstyle)
(insert " *\n")
(insert-license-gpl-multifile-cstyle)
(insert " */\n")
(insert "\n")
(insert "#include \n")
(insert "#include \n")
(insert "#include \n")
(insert "\n")
(insert "int main(int argc, char *argv[]) {\n")
(insert "\n")
(insert "}\n"))

;; C/C++ function header
(global-set-key "\C-t\C-c\C-f" 'insert-c-function-header)
(defun insert-c-function-header () (interactive)
(insert "/*\n")
(insert " * short desc\n")
(insert " *\n")
(insert " * long desc\n")
(insert " */\n")
(insert "int function(void) {\n")
(insert "\n")
(insert "\n")
(insert " return(1);\n")
(insert "}\n")
(insert "\n"))

;; PHP file header
(global-set-key "\C-t\C-p\C-h" 'insert-php-file-header)
(defun insert-php-file-header () (interactive)
(defvar projectname (read-string "Project name? "))
(insert " - http://www.nandox.com\n")
(insert " * @todo none\n")
(insert " **/\n")
(insert "\n")
(insert "\n")
(insert "?>\n"))

;; PHP function header
(global-set-key "\C-t\C-p\C-f" 'insert-php-function-header)
(defun insert-php-function-header () (interactive)
(insert "/**\n")
(insert " * short desc\n")
(insert " *\n")
(insert " * long desc\n")
(insert " * @param void\n")
(insert " * @return null\n")
(insert " * @author Hernando Furlan - http://www.nandox.com\n")
(insert " * @todo none\n")
(insert " **/\n")
(insert "function () {\n")
(insert "\n")
(insert "\n")
(insert " return(1);\n")
(insert "}\n")
(insert "\n"))

;; Perl file header
(global-set-key "\C-t\C-e\C-h" 'insert-perl-file-header)
(defun insert-perl-file-header () (interactive)
(defvar projectname (read-string "Project name? "))
(insert "#!/usr/bin/perl -w\n")
(insert "#!/usr/local/bin/perl -w\n")
(insert "\n")
(insert "# -------------------------------------------------------------------------\n")
(insert-copyleft-bashstyle)
(insert "#\n")
(insert-license-gpl-multifile-bashstyle)
(insert "# -------------------------------------------------------------------------\n")
(insert "\n")
(insert "require 5.004;\n")
(insert "use POSIX;\n")
(insert "use strict;\n")
(insert "\n"))

;; Perl function header
(global-set-key "\C-t\C-e\C-f" 'insert-c-function-header)
(defun insert-c-function-header () (interactive)
(insert "# -------------------------------------------------------------------------\n")
(insert "# short desc\n")
(insert "#\n")
(insert "# long desc\n")
(insert "# -------------------------------------------------------------------------\n")
(insert "sub function {\n")
(insert " my (@argv) = @_;\n")
(insert "\n")
(insert "\n")
(insert " return(1);\n")
(insert "}\n")
(insert "\n"))

;; SQL Text comment
(global-set-key "\C-t\C-s\C-h" 'insert-sql-file-header)
(defun insert-sql-file-header () (interactive)
(defvar projectname (read-string "Project name? "))
(insert "-- " projectname " - \n")
(insert "-- $Id: " (file-name-nondirectory (buffer-file-name)) ",v 1.0" (format-time-string " %Y/%m/%d %H:%M:%S ") "nando Exp $\n")
(insert "--\n")
(insert "-- Hernando Furlan \n")
(insert "-- http://www.nandox.com - http://about.nandox.com\n")
(insert "\n"))

;; Plain Text header
(global-set-key "\C-t\C-t\C-h" 'insert-plaintext-file-header)
(defun insert-plaintext-file-header () (interactive)
(insert "# -------------------------------------------------------------------------\n")
(insert "# " (file-name-nondirectory (buffer-file-name)) " - \n")
(insert "# Hernando Furlan \n")
(insert "# http://www.nandox.com - http://about.nandox.com\n")
(insert "# -------------------------------------------------------------------------\n")
(insert "\n"))

(message "Loading of Nando's dot emacs OK!")


{ 5 comentarios... read them below or Comment }

  1. uy, yo me quedo con el vi eh, se gano mi amor

    ResponderEliminar
  2. Ambos están a la misma altura, es cuestión de costumbre.

    Saludos.

    ResponderEliminar
  3. ssshhhhhh! mirá que los del post de al lado se enojan!

    ResponderEliminar
  4. mmm que es lo que se puede hacer no comprendo, por ejemplo si escribo unas lineas de codigo python lo voy a poder correr en la shell precionando F5 ( bueno, no con la misma tecla que el editor de python) se puede llamar la ayuda de python, que es lo magico que hace,
    siempre e utilizado nano, gedith y me gustaria ver un edith como el de DOS en consola linux

    ResponderEliminar

Popular Post

Labels

Seguidores

- Copyright © NandOX Chat - Blog -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan - Modified by NandOX