My Emacs Installation

Source: Internet
Author: User
Tags autoload

Ubuntu 10.10
Emacs23

I have been using Vim for a long time. I often feel that the ESC key makes me very uncomfortable. I always need to press it so far. So I want to use Emacs and install Emacs first.

Apt-Get install Emacs

Oh, at least you can read the text and code. Then I looked at the code without a line number, so I was depressed. Find the solution on the Internet as follows:
Download linum. El
My content is as follows. You can also go online to the next one:
; Linum. El --- display line numbers to the left of Buffers

; Copyright (c) 2007,200 8 Markus Triska

; Author: Markus Triska <markus.triska@gmx.at>
; Keywords: convenience

; This file is free software; you can redistribute it and/or modify
; It under the terms of the GNU General Public License as published
; The Free Software Foundation; either version 3, 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
; Merchantability or fitness for a special purpose. See
; GNU General Public License for more details.

; You shoshould have written ed a copy of the GNU General Public License
; Along with GNU Emacs; see the file copying. If not, write
; The Free Software Foundation, inc., 51 Franklin Street, fifth floor,
; Boston, MA 02110-1301, USA.

; Commentary:

; Display line numbers for the current buffer. Copy linum. El to your
; Load-path and add to your. emacs:

; (Require 'linum)

; Then toggle display of line numbers with m-x linum-mode. To enable
; Line numbering in all buffers, use M-x global-linum-mode.

; Code:

(Defconst linum-version "0.9wza ")

(Defvar linum-overlays nil "overlays used in this buffer .")
(Defvar linum-available nil "overlays available for reuse .")
(Defvar linum-before-numbering-hook Nil
"Functions run in each buffer before line numbering starts .")

(Mapc # 'make-variable-buffer-local' (linum-overlays linum-available ))

(Defgroup linum Nil
"Show line numbers to the left of buffers"
: Group 'convenience)

; ;#### Autoload
(Defcustom linum-format 'dynamic
"Format used to display line numbers. Either a format string
Like \ "% 7D \", 'dynamic to adapt the width as needed, or
Function that is called with a line number as its argument and
Shocould evaluate to a string to be shown on that line. See also
'Linum-before-numbering-hook '."
: Group 'linum
: Type 'sexp)

(Defface linum
'(T: Inherit (shadow default )))
"Face for displaying line numbers in the display margin ."
: Group 'linum)

(Defcustom linum-eager t
"Whether line numbers shoshould be updated after each command.
The conservative setting 'nil 'might miss some buffer changes,
And you have to scroll or press c-l to update the numbers ."
: Group 'linum
: Type 'boolean)

(Defcustom linum-delay Nil
"Delay updates to give Emacs a chance for other changes ."
: Group 'linum
: Type 'boolean)

; ;#### Autoload
(Define-minor-mode linum-Mode
"Toggle display of line numbers in the left marginal area ."
: Lighter ""; for desktop. El
(If linum-Mode
(Progn
(If linum-eager
(Add-hook 'post-command-hook (if linum-Delay
'Linum-schedule
'Linum-Update-current) Nil T)
(Add-hook 'after-change-Functions 'linum-after-change nil t ))
(Add-hook 'window-scroll-Functions 'linum-after-scroll nil T)
; Mistake in Emacs: window-size-change-functions cannot be local
(Add-hook 'window-size-change-Functions 'linum-after-size)
(Add-hook 'change-Major-mode-hook 'linum-delete-overlays nil T)
(Add-hook 'window-configuration-change-hook
'Linum-after-config nil T)
(Linum-Update-current ))
(Remove-hook 'post-command-hook 'linum-Update-current T)
(Remove-hook 'post-command-hook 'linum-Schedule T)
(Remove-hook 'window-size-change-Functions 'linum-after-size)
(Remove-hook 'window-scroll-Functions 'linum-after-scroll T)
(Remove-hook 'after-change-Functions 'linum-after-change T)
(Remove-hook 'window-configuration-change-hook 'linum-after-config T)
(Remove-hook 'change-Major-mode-hook 'linum-delete-overlays T)
(Linum-delete-overlays )))

; ;#### Autoload
(Define-globalized-minor-mode global-linum-mode linum-on)

(Defun linum-on ()
(Unless (minibufferp)
(Linum-mode 1 )))

(Defun linum-delete-overlays ()
"Delete All overlays displaying line numbers for this buffer ."
(Mapc # 'delete-overlay linum-overlays)
(Setq linum-overlays nil)
(Dolist (w (get-buffer-window-List (current-buffer) Nil t ))
(Set-window-margins w 0 )))

(Defun linum-Update-current ()
"Update line numbers for the current buffer ."
(Linum-Update (current-buffer )))

(Defun linum-Update (buffer)
"Update line numbers for all windows displaying buffer ."
(With-current-buffer Buffer
(When linum-Mode
(Setq linum-available linum-overlays)
(Setq linum-overlays nil)
(Save-excursion
(Mapc # 'num-Update-Window
(Get-buffer-window-LIST Buffer nil 'visible )))
(Mapc # 'delete-overlay linum-available)
(Setq linum-available nil ))))

(Defun linum-Update-window (WIN)
"Update line numbers for the portion visible in window win ."
(Goto-CHAR (window-start win ))
(Let (line-number-at-Pos ))
(Limit (window-end win t ))
(FMT (cond (stringp linum-format)
(EQ linum-format 'dynamic)
(Let (w (length (number-to-string
(Count-lines (point-min) (point-max ))))))
(Concat "%" (number-to-string W) "D ")))))
(Width 0 ))
(Run-hooks 'linum-before-numbering-hook)
; Create an overlay (or reuse an existing one) for each
; Line visible in this window, if necessary.
(While (and (not (eobp) (<= (point) limit ))
(Let * (STR (if FMT
(Propertize (format FMT line) 'face' linum)
(Funcall linum-format line )))
(Visited (catch 'visited
(Dolist (O (overlays-in (point )))
(When (string = (overlay-Get o 'linum-Str)
(Unless (memq o linum-overlays)
(Push o linum-overlays ))
(Setq linum-available (delete o linum-available ))
(Throw' visited t ))))))
(Setq width (max width (length Str )))
(Unless visited
(Let (OV (if (null linum-available)
(Make-overlay (point ))
(Move-overlay (POP linum-available) (point )))))
(Push ov linum-overlays)
(Overlay-put ov 'before-string
(Propertize "" 'display' (margin left-margin), STR )))
(Overlay-put ov 'linum-str Str ))))
(Forward-line)
(Setq line (1 + line )))
(Set-window-margins win width )))

(Defun linum-after-change (beg end Len)
; Update overlays on deletions, and after newlines are inserted
(When (or (= beg end)
(= End (point-max ))
; Todo: Use string-match-P with CVS or new release
(String-match "\ n" (buffer-substring-no-properties beg end )))
(Linum-Update-current )))

(Defun linum-after-scroll (WIN start)
(Linum-Update (window-buffer win )))

(Defun linum-after-size (FRAME)
(Linum-after-config ))

(Defun linum-schedule ()
; Schedule an update; the delay gives Emacs a chance for display changes
(Run-with-idle-timer 0 nil # 'linum-Update-current ))

(Defun linum-after-config ()
(Walk-Windows (lambda (w) (linum-Update (window-buffer W) Nil 'visible ))

(Provide 'linum)
; Linum. El ends here

You can copy the file and name it linum. El.
I put linum. El in ~ /. Emacs. d/package/directory ,~ /. Emacs configuration is as follows:
; Displays the row number
(Add-to-list 'Load-path "~ /. Emacs. d/package ")
(Load "linum. El ")
(Require 'linum)
(Global-linum-mode 1)

In this way, the row number can be displayed. Haha, the first step is successful. Although I don't know the meaning of add-to-list and load-path, I will learn it later.

Then I found that when I used Emacs to input the. emacs file, I couldn't enter Chinese. That is the comment. It hurts again. If I don't have any Chinese Input, I will use a fart. Check it online.

I used scim, but I still feel full of it.
Scim installation becomes simpler and simpler. I used to perform the following two steps when I installed the blank Host:
Apt-Get install scim

Then add a file in the/etc/X11/xsession. d/directory, 95 xinput, and write the following content:
/Usr/bin/scim-d

Xmodifiers = "@ im = scim"
Export xmodifiers
Export gtk_im_module = scim

I found that I was wrong.

Emacs cannot directly call scim. It has not been solved for half a day. After finding scim-bridge, we can find it on the Wiki. Therefore, we have to go to these websites frequently in Linux, I directly paste the content I see:

Scimbridge Chinese

The scim-bridge.el is the scim-bridge client in GNU Emacs)

Scim-bridge.el can save the input states in different caches, so that you can quickly enter Chinese in Emacs, rather than switching the global input state repeatedly, very convenient.
Contents

1. What is scim?
2. Installation
3. Custom
4.

What is scim?

Scim is a general-purpose smart Input Method platform that supports Chinese, Japanese, Korean, and many European languages. It can be used in POSIX operating systems, including Linux and BSD.
Install

* Install scim:
O In Debian, the steps are very simple:

Sudo aptitude install scim-bridge-Agent scim-bridge-client-GTK scim-bridge-client-qt4 scim-qtimm-y

O you can also use the following commands to install the "PinYin Input Method ":

Sudo aptitude install scim-pinyin-y

* Install scim-bridge.el:
O download the latest package from scim-bridge.el project in launchpad.
O enable Emacs to disable xim:
+ Add the following command ~ /. Xresources:

Emacs * usexim: false

+ Execute the following command to take effect:

Xrdb ~ /. Xresources

O add scim-bridge.el to load-path:
+ Decompress the scim-bridge package and place it in "~ /Elisp directory, and then add the following command ~ /. Emacs:

(Add-to-list 'Load-path (expand-file-name "~ /Elisp "))

O modify the switch key of scim:
+ The CTRL-Space key should be bound by Emacs by default. Therefore, you must add other keys in the scim graphic settings interface, such as super-space (other keys are also supported ).
O load and set the scim-bridge.el:
+ Add the following ~ /. Emacs:

; Load.
(Require 'scim-bridge-ZH-Si)
; If you use traditional Chinese, replace it with (require 'scim-bridge-ZH-Tr.
; Load ~ /. Automatically enable scim-mode after Emacs.
(Add-hook 'after-init-call' scim-mode-on)
; Set the input method switch key
(Scim-define-common-Key (KBD "s-SPC") T)
; Use the C-SPC as the markup command.
(Scim-define-common-Key (KBD "C-SPC") nil)
; Use C-/as the undo command.
(Scim-define-common-Key (KBD "C-\") nil)
; Set the cursor color in different input states.
(Setq scim-cursor-color '("red" "blue" "limegreen "))

Click suepr-space to enter Chinese.

Custom

* You can customize the scim-bridge.el in the following ways:

M-x Customize-group RET scim-bridge RET

I have translated relevant documents into simplified Chinese and Traditional Chinese, enjoy!

Step by step, the switch key of scim is changed to shift-space, and the others are exactly the same. Then, enable Emacs to switch the input method. Previously with those what lc_ctype = zh_CN.UTF-8 Emacs, you can pop up scim, The results only English, my grandmother, play more than no pop-up makes me a pain.

Now I can pop up the scim box, and it does have four words: intelligent pinyin. I was depressed and found that I can only enter Chinese characters. What about my days, it also makes people alive.
I went on to find a solution and found that this was not the case on the Internet. Many networks of my company's own machines were not accessible. We used remote clients. Inadvertently, when I used Firefox on the local machine for query (I usually don't need to access the Internet on the local machine), I found that I couldn't enter Chinese. I knew it was not an Emacs problem, but it was a problem with my scim, I saw someone on the internet saying that ibus can be used to input Chinese Characters in Emacs. I deleted scim and installed an ibus, in addition, if ibus-El cannot be found on our limited network, it will delete ibus again and reload scim. I almost betrayed it, but I finally came back. At this time, there was a problem, I don't know if I want to install scim-pinyin. When I first installed scim-pinyin, I wrapped it in by default, but this time he didn't install it for me and found this problem, I finally got it done.

Scim is okay, and Emacs is okay. My journey to Emacs is about to begin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.