s/Vim/Emacs/

Software besorgen und anwenden
Post Reply
Message
Author
bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

s/Vim/Emacs/

#1 Post by bakunin »

Hi!

Ich hoffe, der Titel ist nicht zu provokativ. <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">

Seit sehr langer Zeit sage ich mir: "Ich würde ja Emacs einsetzen, wenn...". Leider erfüllt sich dieses "wenn" nicht von selbst.

Ich verwende seit langer Zeit Vim. Aber es gibt zahlreiche Gründe, aus denen ich GNU Emacs einsetzen möchte, nur dieser Umstieg fällt mir etwas schwer, weil ich in Vim einfach schon zu vieles sehr schnell machen kann.

Ja, ich habe das Emacs-Tutorial durchgearbeitet. Aber das reicht halt einfach nicht. Ich habe mir auch schon Viper angesehen (VI-Modus für Emacs), aber das bringt's einfach nicht, weil ich dabei letztlich auch nicht viel über Emacs lerne und vieles vermisse, was Vim bietet, d.h. das ist eigentlich eher kontraproduktiv.

Gibt es ein Vi-nach-Emacs-Migrations-HOWTO oder sowas?

Ok, mit GNU Emacs 21 ist es mir erstmals gelungen, Syntax-Highlighting nicht nur in X11, sondern auch auf der Konsole zu erhalten, aber das auch nur Dank eines Menüpunktes in der X11-Versioni, d.h. was mir dabei in meine ".emacs" geschrieben wurde, verstehe ich nicht ansatzweise, was so nicht bleiben darf. Ich möchte hierbei anmerken, dass ich an sich durchaus bereit bin, ELISP zu lernen und auch schon einmal damit angefangen hatte.

Konkret würde ich z.B. gerne wissen, wie ich in Emacs folgendes erreichen kann (Tausend weitere Sachen werden mir später einfallen):

- Markerungen in der Datei setzen und zu diesen springen. ("mx" und "'x" in vi)
- Suche-Ersetze Oprationen auf einen Bereich anwenden (z.B. ":.,$s/^/# /g" in vi)
- Automatische Einrückung, die einfach nur so weit einrückt, wie die vorherige Zeile eingerückt war. Sonst nix.
- Zeilennummern am Anfang der Zeilen. Wie ":set nu" in vim. Das wäre sehr nett, aber ist nicht lebenswichtig.
- Ich hasse es, mit dem Cursor durch Tabulatoren zu navigieren. Ich hasse es! Also sollte die automatische Einrückung keine Tabulatoren produzieren. Nur in Dateien wie "Makefile" und "*.mgp" brauche ich natürlich Tabulatoren auch bei auto-indent.
- Wie erreicht man schnelle Cut-Paste Möglichkeiten, also sowas wie "5dd" in vi?

Bevor ich solche Sachen nicht machen kann, kann ich gar nicht erst anfangen, Emacs ernsthaft einzusetzen. Und wenn ich nicht Emacs ernsthaft einsetze, kann ich auch nicht viel über Emacs lernen und werde nur noch erfahrener mit Vim - Ein Teufelskreis.

Cheers,
GNU/Wolfgang, der es außerordentlich interessant findet, was sich unterhalb der Tasten einer Tastatur im Laufe der Zeit so alles ansammelt. <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">

Descartes

Re: s/Vim/Emacs/

#2 Post by Descartes »

> ... Also sollte die automatische Einrückung keine Tabulatoren produzieren. ...
ich denke dass (setq indent-tabs-mode nil) das ist was du suchst

Eine Übersicht dier Tastenbelegung findest du u.a. auf:

Emacs Quick Reference
<a href="http://seamons.com/emacs/" target="_blank"><!--auto-->http://seamons.com/emacs/</a><!--auto-->

MSU - Computer Science and Engineering - Text Editors - Emacs (and XEmacs)
<a href="http://www.cse.msu.edu/facility/edit.php" target="_blank"><!--auto-->http://www.cse.msu.edu/facility/edit.php</a><!--auto-->

Beispielkonfigurationen gibts auf:

The very unofficial dotemacs home
<a href="http://www.dotemacs.de/" target="_blank"><!--auto-->http://www.dotemacs.de/</a><!--auto-->


Ansonsten hadere ich mit ähnlichen Umstiegsproblemen von vim -> (X)Emacs. Im Januar habe mich mal hingesetzt aus verschiedenen aus dem Internet zusammengeklaubten (X)Emacs Konfigurationsdateien einen ersten Entwurf einer für mich sinnvollen Konfiguration erstellt die ich für GNU/Emacs und XEmacs unter Windows, Solaris/SPARC und Linux verwende.
Soweit möglich habe ich Kommentare aus den Quellen übernommen. Bei Java Quellcode habe ich allerdings noch das Problem, dass die Einrückungen mit Tabstops gemacht werden -- und zwar mit viel zu vielen Tabstops. Wenn man die Files dann mit einem anderen Editor öffnet fängt der Text irgendwo am rechten Bildschirmrand an <img src="http://www.pl-forum.de/UltraBoard/Images/Sad.gif" border="0" align="middle">

<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
;; ==================================================================
;; BEGIN-OF-FILE
;; =============

;; File(s): ~/.emacs
;; ~/.xemacs/custom.el
;; Author: Descartes
;; Date: 2002-01-26
;;
;;
;; Thanks to
;; File: .emacs
;; http://www.dotemacs.de/dotfiles/BenjaminRutt.emacs.html
;; Author: Benjamin Rutt
;; Email: brutt@bloomington.in.us
;;
;; File: .emacs
;; http://www.dotemacs.de/dotfiles/GaryFong.emacs.html
;; Author: Gary Fong


;; ==================================================================
; set up my tab length as a variable
(defun get-my-tab-length () 2)
(defun get-my-frame-width () 80)
(defun get-my-frame-height () 40)

(defvar my-emacs-type
(if (string-match "XEmacs\<!--no-->|Lucid" (emacs-version))
'xemacs
'fsf_emacs)
"The type of emacs running, either 'fsf_emacs' or 'xemacs'. \
Uses 'emacs-version' to determine type.")

;; ==================================================================
;; misc customizing
;; ================
(custom-set-variables
'(c-indent-comments-syntactically-p t)
'(c-syntactic-indentation t)
'(compilation-ask-about-save nil)
'(Man-notify-method (quote bully))
'(compilation-window-height 10)
'(scroll-bar-mode nil)
'(c++-font-lock-extra-types (quote ("JBF[a-zA-Z0-9]*" "eZ[a-zA-Z0-9]*" "Q[a-zA-Z]*" "uint" "ulong" "string")))
'(compile-command "make")
'(kill-whole-line t)
'(compilation-read-command nil)
'(column-number-mode t)
'(line-number-mode t)
'(paren-mode (quote sexp) nil (paren))
'(global-font-lock-mode t)
'(font-lock-use-colors t)
'(font-lock-use-fonts nil)
'(user-mail-address "descartes@localhost")
'(query-user-mail-address nil)
'(display-time-day-and-date t)
)

(if (eq my-emacs-type 'x_emacs)
(custom-set-faces
'(default ((t (:size "10pt" :family nil))) t)))

;; ==================================================================
;; AutoSave
;; ========
;; Load the auto-save.el package, which lets you put all of your autosave
;; files in one place, instead of scattering them around the file system.
;;

(defun config-my-autosave ()
(setq auto-save-directory (expand-file-name "~/.xemacs-autosave/")
auto-save-directory-fallback auto-save-directory
auto-save-hash-p nil
efs-auto-save t
efs-auto-save-remotely nil
;; now that we have auto-save-timeout, let's crank this up
;; for better interactive response.
auto-save-interval 2000
)
;; We load this afterwards because it checks to make sure the
;; auto-save-directory exists (creating it if not) when it's loaded.
(if (eq my-emacs-type 'x_emacs)
(if (and running-emacs
(or (and (= emacs-major-version 20) (>= emacs-minor-version 1))
(and (= emacs-major-version 19) (>= emacs-minor-version 15))))
(require 'auto-save))
))

;; ==================================================================
;; Fonts
;; ============
;;
(setq font-lock-maximum-decoration t)
;; activate syntax highlighting for the following language-modes:
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
(add-hook 'cc-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(add-hook 'c++-mode-hook 'turn-on-font-lock)
(add-hook 'html-mode-hook 'turn-on-font-lock)
(add-hook 'java-mode-hook 'turn-on-font-lock)
(add-hook 'makefile-mode-hook 'turn-on-font-lock)
(add-hook 'perl-mode-hook 'turn-on-font-lock)
(add-hook 'sh-mode-hook 'turn-on-font-lock)
(add-hook 'shell-script-mode-hook 'turn-on-font-lock)
(add-hook 'xrdb-mode-hook 'turn-on-font-lock)

;; ==================================================================
;; Window colors
;; =============
;;
(if (eq window-system 'x)
(if (x-display-color-p)
(progn
(set-background-color "#FFFFEEEECCCC")
(set-foreground-color "black")
(set-face-background 'region "black")
(set-face-foreground 'region "#FFFFEEEECCCC")
(set-face-background 'highlight "yellow")
(set-face-foreground 'highlight "black")
(set-face-background 'secondary-selection "#FFFFEEEECCCC")
(set-face-foreground 'secondary-selection "black")
(set-face-background 'modeline "gold1")
(set-face-foreground 'modeline "black")
(setq x-pointer-shape x-pointer-left-ptr)
(set-cursor-color "red")
(set-mouse-color "blue")
)))

(setq default-frame-alist
(append
'((width . (get-my-frame-width))
(height . (get-my-frame-height))
(background-color . "#FFFFEEEECCCC")
(foreground-color . "black")
(mouse-color . "blue")
(cursor-color . "red")
(face-color . "black")
(face-backgound-color . "#FFFFEEEECCCC")
) default-frame-alist))

(setq pop-up-frame-alist
'((width . (get-my-frame-width))
(height . (get-my-frame-height))
(background-color . "#FFFFEEEECCCC")
(foreground-color . "black")
(mouse-color . "blue")
(cursor-color . "red")
))

(set-frame-height (selected-frame) (get-my-frame-height))
(set-frame-width (selected-frame) (get-my-frame-width))

;; ==================================================================
;; Text Options
;; ============

;; (setq-default fill-column 70)
;; (setq-default fill-prefix " ")

;; ==================================================================
;; Time & Date Options
;; ===================

(setq supress-day-of-week nil)
(setq display-time-day-and-date t)

;; ==================================================================
;; Mode Options
;; ============

(autoload 'c++-mode "cc-mode" "C++ Editing Mode" t)
(autoload 'c-mode "cc-mode" "C Editing Mode" t)
(autoload 'objc-mode "cc-mode" "Objective C Editing Mode" t)
(autoload 'text-mode "indented-text-mode" "Indented Text Editing Mode" t)
(autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
(autoload 'ps-mode "ps-mode" "Major mode for editing PostScript" t)

;; This adds additional extensions which indicate files normally
;; handled by cc-mode.
(setq auto-mode-alist
(append '(("\<!--no-->.C$" . c++-mode)
("\<!--no-->.c$" . c++-mode)
("\<!--no-->.cc$" . c-mode)
("\<!--no-->.h$" . c++-mode)
("\<!--no-->.hh$" . c++-mode)
("\<!--no-->.i$" . c++-mode)
("\<!--no-->.ii$" . c++-mode)
("\<!--no-->.m$" . objc-mode)
("\<!--no-->.pl$" . perl-mode)
("\<!--no-->.sql$" . c-mode)
("\<!--no-->.sh$" . shell-script-mode)
("\<!--no-->.mak$" . makefile-mode)
("\<!--no-->.GNU$" . makefile-mode)
("makefile$" . makefile-mode)
("Imakefile$" . makefile-mode)
("\<!--no-->.Xdefaults$" . xrdb-mode)
("\<!--no-->.Xenvironment$" . xrdb-mode)
("\<!--no-->.Xresources$" . xrdb-mode)
("*.\<!--no-->.ad$" . xrdb-mode)
("\<!--no-->.[eE]?[pP][sS]$" . ps-mode)
) auto-mode-alist))

(setq default-tab-width (get-my-tab-length))
(setq initial-major-mode 'text-mode)
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(global-unset-key "\M-[")
(global-unset-key "\M-O")
(setq default-auto-fill-hook 'do-auto-fill)
(add-hook 'c-mode-common-hook
'(lambda () (c-toggle-auto-hungry-state 1)))
(add-hook 'c-mode-common-hook '(lambda () (c-set-style "Ellemtel")))

;; ==================================================================
;; Mode Options :: C/C++
;; =====================

(defun my-c-mode-hook ()
; do not use tab-stops for indent
(setq indent-tabs-mode nil)

(setq tab-width (get-my-tab-length))
(setq c-basic-offset (get-my-tab-length))
(setq standard-indent (get-my-tab-length))
(setq c-style-variables-are-local-p nil)

; indent GNU-Style
; (c-set-offset ... 1) (c-set-offset ... 0)
; if (0) becomes if (0)
; { {
; ; ;
; } }
(c-set-offset 'substatement-open (get-my-tab-length))

; switch/case: make each case line indent from switch
(c-set-offset 'case-label '+)

; make the ENTER key indent next line properly
(local-set-key "\C-m" 'newline-and-indent)

; make a #define be left-aligned
(setq c-electric-pound-behavior (quote (alignleft)))

; do not impose restriction that all lines not top-level
; be indented at least 1 (was imposed by gnu style by default)
(setq c-label-minimum-indentation 0)
)
(add-hook 'c++-mode-hook 'my-c-mode-hook)
(add-hook 'c-mode-hook 'my-c-mode-hook)

;; ==================================================================
;; Dired Options
;; =============
;;

(defun config-my-dired-options ()
(add-hook 'dired-load-hook
(function (lambda ()
; (load "dired-x")
(define-key dired-mode-map "a" 'dired-mark-extension)
(define-key dired-mode-map "b" 'dired-flag-extension)
(define-key dired-mode-map "E" 'dired-unmark-all-files-no-query)
(define-key dired-mode-map "\M-!" 'background)
(setq dired-listing-switches "-alF"
dired-ls-F-marks-symlinks t
dired-bind-vm t
dired-dwim-target t
dired-guess-shell-gnutar "gnutar"
dired-guess-shell-alist-user '(("\<!--no-->.tgz$" "gnutar zxvf"))))))
(setq dired-enable-local-variables nil)
(setq dired-local-variables-file nil))

;; ==================================================================
;; Full ISO Latin-1 Character Set
;; ==============================

(standard-display-european 1)
(load "iso-insert")

;; ==================================================================
;; Move date and time to frame-status line
;; =======================================
(defun config-my-statusline ()
; (display-time)
(setq global-mode-string '("" vip-mode string))
(setq frame-title-format
'(multiple-frames "%b" ("" invocation-name "@" system-name " :: " display-time-string)))
(if (not (fboundp 'display-time))
(load "time"))
(display-time)
)

;; ==================================================================
;; Key Bindings
;; ============
(define-key global-map "\M-OP" 'describe-bindings)
;; map "indent-region" to "C-c i"
;; (global-set-key "\C-ci" 'indent-region)
;; (global-set-key [(control c) i] 'indent-region)

(global-set-key [(control x)g] 'goto-line)

(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [(control home)] 'beginning-of-buffer)
(global-set-key [(control end)] 'end-of-buffer)

(global-set-key [(shift tab)] 'indent-region)
;; f2
(global-set-key [f2] 'ispell-buffer)
;; f3
(global-set-key [f3] 'insert-c++-function-header)
(global-set-key [(shift f3)] 'insert-c++-class-header)
(global-set-key [(control f3)] 'auto-insert)
(global-set-key [(meta f3)] 'insert-c++-class)
;; f4
(global-set-key [f4] 'imenu)
;; f5
(global-set-key [f5] 'copy-file)
;; f6
(global-set-key [f6] 'delete-file)
;; f7
(global-set-key [f7] 'rename-file)
;; f8
;; f9
(global-set-key [f9] 'compile)
;; f10
;; f11
(global-set-key [f11] 'calendar)
;; f12

;; (global-set-key "\C-x\C-b" 'electric-buffer-list)
(global-set-key [(control x)(control b)] 'electric-buffer-list)

(defalias 'switch-to-next-buffer 'bury-buffer)
(defun switch-to-previous-buffer ()
"Switches to previous buffer"
(interactive)
(switch-to-buffer (nth (- (length (buffer-list)) 1) (buffer-list)))
)
(global-set-key [(control tab)] 'switch-to-previous-buffer)
(global-set-key [(control backtab)] 'switch-to-next-buffer)

;; ==================================================================
;; Desktop
;; =======

(load "desktop")
(desktop-load-default)
(desktop-read)

;; ==================================================================
;; Makefile Options
;; ================

(setq makefile-electric-keys t)

;; ==================================================================
;; Compilation Options
;; ===================
(defun config-my-compilation-options ()
(setq compile-command "make -k")
(setq compilation-window-height 20)
(defadvice compile-internal (after my-scroll act comp)
"Forces compile buffer to scroll "
(let* ((ob (current-buffer))
(obw (get-buffer-window ob t))
win
)
(save-excursion
(if (or (null (setq win (get-buffer-window ad-return-value t)))
(null obw))
nil
(select-window win)
(goto-char (point-max))
(select-window obw)
)))))

;; ==================================================================
;; GENERAL FUNCTIONS
;; =================
;; Author: GaryFong

;; ------------------------------------------------------------------
;; Inserts a C function header.
;; ----------------------------
(defun insert-c-function-header ()
"Inserts a C function header which conforms to Oacis standards."
(interactive)
(insert
"/******************************************************************************\<!--no-->n"
"*\<!--no-->n"
"* Function: \<!--no-->n"
"*\<!--no-->n"
"* Purpose: \<!--no-->n"
"*\<!--no-->n"
"* Params: \<!--no-->n"
"*\<!--no-->n"
"* Returns: \<!--no-->n"
"*\<!--no-->n"
"* Statuses: \<!--no-->n"
"*\<!--no-->n"
"******************************************************************************/\<!--no-->n"
"\<!--no-->n")
(message "Inserted C function header")
)

(defun insert-c++-function-header ()
"Inserts a C++ function header which conforms to Oacis standards."
(interactive)
(insert
"//-----------------------------------------------------------------------------\<!--no-->n"
"// Function:\t\<!--no-->n"
"// Purpose:\t\<!--no-->n"
"// Params:\t\t\<!--no-->n"
"// Returns:\t\<!--no-->n"
"// Exceptions:\t\<!--no-->n"
"// Precond:\t\<!--no-->n"
"// Postcond:\t\<!--no-->n"
"//-----------------------------------------------------------------------------\<!--no-->n"
"\<!--no-->n"
"return opname(argname) const throw(Err)\<!--no-->n"
"{\<!--no-->n"
"}\<!--no-->n"
"\<!--no-->n")
(message "Inserted C++ function header")
)

(defun insert-c++-class-header ()
"Inserts a C++ class header which conforms to Oacis standards."
(interactive)
(insert
"//-----------------------------------------------------------------------------\<!--no-->n"
"// Class:\t\t_class_\<!--no-->n"
"// Purpose:\t\<!--no-->n"
"//-----------------------------------------------------------------------------\<!--no-->n"
"\<!--no-->n")
(message "Inserted C++ class header")
)

(defun insert-c++-class ()
"Inserts a C++ class which conforms to Oacis standards."
(interactive)
(insert-c++-class-header)
(insert
"class _class_\<!--no-->n"
"{\<!--no-->n"
"public:\<!--no-->n"
"\<!--no-->n"
" // Constructor/destructor.\<!--no-->n"
" _class_();\<!--no-->n"
" virtual ~_class_();\<!--no-->n"
"\<!--no-->n"
"private:\<!--no-->n"
"\<!--no-->n"
" // Unused ctor and assignment op.\<!--no-->n"
" _class_(const _class_&);\<!--no-->n"
" _class_& operator=(const _class_&);\<!--no-->n"
"};\<!--no-->n"
"\<!--no-->n")
(message "Inserted C++ class")
)

;; ==================================================================
;; LOCAL HOOKS SECTION
;; ===================
;; note this section should be last to allow an .emacs_local file to
;; override the .emacs. The .emacs_local file should contain
;; anything specific to a particular environment/platform/machine.
(if (file-exists-p "~/.emacs_local")
(load-file "~/.emacs_local"))

(config-my-compilation-options)
(config-my-autosave)
(config-my-statusline)
(config-my-dired-options)

;; ==================================================================
;; END-OF-FILE
;; ===========
</font><hr></pre></blockquote>

bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

Re: s/Vim/Emacs/

#3 Post by bakunin »

Hi Descartes!

Krass, vielen Dank. Solche Tipps kann ich wirklich gebrauchen. Ich werde mir das mal alles ansehen, wenn ich etwas Zeit dafür habe. Vermutlich nicht morgen, weil ich für Dienstag noch ein englischsprachiges Referat über RMS machen muss. :)

Cheers,
GNU/Wolfgang

User avatar
heinrich
Posts: 219
Joined: 22. Sep 1999 11:22
Location: N49.137 E8.544

Re: s/Vim/Emacs/

#4 Post by heinrich »

Kleine Anpassung. Rest der Config wie oben.
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
;; ==================================================================
;; BEGIN-OF-FILE
;; =============
;;
;; ################################################################
;; ## ##
;; ## Filename : ~/.emacs ##
;; ## ~/.xemacs/custom.el ##
;; ## Short description: Emacs configuration file ##
;; ## Operating System : n/a ##
;; ## Author : Thomas Gern ##
;; ## ICN WN OP TDC EP ##
;; ## Created : 2002-01-26 ##
;; ## Last Changed : 2002-02-04 ##
;; ## Latest Version : 1.1 ##
;; ## ##
;; ## Changelog : ##
;; ## ----------- ##
;; ## Nr. Name Department Date Version ##
;; ##------------------------------------------------------------##
;; ## | ##
;; ## 01 | Gern TDC EP 2002-01-26 1.0 ##
;; ## | ##
;; ## | initial release ##
;; ## | ##
;; ## 02 | Gern TDC EP 2002-02-04 1.1 ##
;; ## | ##
;; ## | added comments in "misc customizing" ##
;; ## | use font-lock (syntax hilighting) for all files ##
;; ## | ##
;; ##------------------------------------------------------------##
;; ## ##
;; ################################################################
;; # #
;; # start with : n/a #
;; # #
;; # optional Parameter : none #
;; # #
;; # mandatory parameter : none #
;; # #
;; ################################################################
;; # #
;; # Depends on: #
;; # #
;; # GNU/Emacs and XEmacs configuration files from: #
;; # #
;; # Benjamin Rutt #
;; # http://www.dotemacs.de/dotfiles/BenjaminRutt.emacs.html #
;; # #
;; # Gary Fong #
;; # http://www.dotemacs.de/dotfiles/GaryFong.emacs.html #
;; # #
;; ################################################################

;; ==================================================================
; set up my tab length as a variable
(defun get-my-tab-length () 2)
(defun get-my-frame-width () 80)
(defun get-my-frame-height () 40)

(defvar my-emacs-type
(if (string-match "XEmacs\<!--no-->|Lucid" (emacs-version))
'xemacs
'fsf_emacs)
"The type of emacs running, either 'fsf_emacs' or 'xemacs'. \
Uses 'emacs-version' to determine type.")

;; ==================================================================
;; misc customizing
;; ================
(custom-set-variables
'(c-indent-comments-syntactically-p t) ; indent comments
'(c-syntactic-indentation t) ; indent syntactic
'(compilation-ask-about-save nil)
'(compilation-read-command nil)
'(compilation-window-height 10)
'(compile-command "make")
'(Man-notify-method (quote bully))
'(scroll-bar-mode nil)
'(c++-font-lock-extra-types (quote ("JBF[a-zA-Z0-9]*"
"eZ[a-zA-Z0-9]*"
"Q[a-zA-Z]*"
"uint" "ulong"
"string")))
'(kill-whole-line t)
'(column-number-mode t) ; show column number (status bar)
'(line-number-mode t) ; show line number (status bar)
'(paren-mode (quote sexp) nil (paren))
'(font-lock-mode t nil (font-lock)) ; enable syntax hilighting
'(global-font-lock-mode t) ; --- " ---
'(font-lock-use-colors t) ; --- " --- use colors
'(font-lock-use-fonts nil) ; --- " --- dont use different font styles
'(user-mail-address "thomas@localhost") ; email address (dummy)
'(query-user-mail-address nil) ; dont ask for email address
'(display-time-day-and-date t) ; show time and date (status bar)
)

(if (eq my-emacs-type 'x_emacs) ; only for XEmacs
(custom-set-faces
'(default ((t (:size "10pt" :family nil))) t))) ; set font size to 10pt

;; ==================================================================
;; AutoSave
;; ========

;; ... rest wie oben ...
</font><hr></pre></blockquote>

bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

Re: s/Vim/Emacs/

#5 Post by bakunin »

Hi!

Ja, ich grabe den alten Thread nochmal aus, um etwas hinzuzufügen:

Offenbar verfügt Emacs nur über eine Markierung pro Buffer. Da ich aber sowiso etwas elisp üben wollte, habe ich mal ein paar Funktionen zum Verwenden von benannten Markierungen (wie mX und 'X in vi) geschrieben, obwohl es sowas bestimmt schon irgendwo gibt. Bei mir hat es bisher funktioniert, aber ich garantiere für nichts. Erweiterungswünsche sind willkommen, ebenso wie Verbesserungsvorschläge auf Code-Ebene.

<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
;; nmarks.el - Set named marks, similar to the mX and 'X commands in vi.
;; Copyright (C) 2002 Wolfgang Jährling <wolfgang@pro-linux.de>
;;
;; This is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

(defvar nmarks-list () "List of nmarks.")

(defun nmarks-set (name)
"Set a named mark to the current point position."
(interactive "cSet nmark: ")
(let ((node (nmarks-get-node name nmarks-list)))
(if node
;; Modify existing entry:
(setcdr node (point))
;; Create new entry:
(setq nmarks-list (cons (cons name (point)) nmarks-list))))
(message "Mark `%c' set." name))

(defun nmarks-push-mark (name)
"Set the buffer mark to a named mark."
(interactive "cSet buffer mark to nmark: ")
(let ((node (nmarks-get-node name nmarks-list)))
(if node
(push-mark (cdr node))
(message "The `%c' nmark is not set." name))))

(defun nmarks-goto (name)
"Jump to a named mark. Set the buffer mark to the old point position."
(interactive "cGoto nmark: ")
(nmarks-goto-internal name nil))

(defun nmarks-goto-keep-mark (name)
"Jump to a named mark while keeping the buffer mark."
(interactive "cGoto nmark: ")
(nmarks-goto-internal name t))

(defun nmarks-mark-region (name-mark name-point)
"Set buffer mark and point to named marks."
(interactive "cSet buffer mark to nmark: \<!--no-->ncSet point to nmark:")
(nmarks-goto-internal name-mark t)
(nmarks-goto-internal name-point nil))

;;; Non-interactive functions for internal use.

(defun nmarks-get-node (name node)
"Search for the node that represents a named mark."
(if node
(if (equal (caar node) name)
(car node)
(nmarks-get-node name (cdr node)))
nil))

(defun nmarks-goto-internal (name keep-mark)
"Place point at a named mark.
Depending on the value KEEP-MARK, either set the buffer mark to the old
position of point or not."
(let ((node (nmarks-get-node name nmarks-list)))
(if (not node)
(message "The `%c' nmark is not set." name)
(or keep-mark (push-mark (point)))
(goto-char (cdr node)))))
</font><hr></pre></blockquote>

Cheers,
GNU/Wolfgang

Post Reply