Copy and paste of Emacs

Source: Internet
Author: User

Increase the copy and paste capabilities of Emacs. By defining several replication functions, copy the relevant data to the delete ring, and then define the shortcut keys for those functions. Paste can be implemented with Ctrl+y. The present. The Emacs file reads as follows:

(setq initial-frame-alist ' (0) (left. 0) (width. 1024) (height. 768))
(Column-number-mode t)
(Transient-mark-mode t)
(setq Line-number-mode T)
;;( SETQ default-tab-width 8)
(setq default-tab-width 4)
(customize-set-variable ' Scroll-bar-mode ' right)
(setq default-directory "/home/zhouyi198631/study")
(setq inhibit-startup-message T)
(setq Global-font-lock-mode T)
(setq make-backup-files Nil)
(setq auto-save-mode Nil)
(setq X-select-enable-clipboard T)
(setq mouse-yank-at-point T)
;;( Define-key Global-map [Home] ' Beginning-of-buffer)
;;( Define-key global-map [end] ' End-of-buffer)
(Define-key Global-map [F3] ' display-line-number-mode-on)
(Define-key global-map [c-f4] ' Other-window)
(Define-key global-map [F5] ' Redraw-display)
(Define-key global-map [F7] ' compile)
(Setq-default Compile-command "make")
;;( Define-key Global-map [F8] ' Du-onekey-compile)
(Define-key Global-map [F6] ' gdb)
(Define-key global-map [c-f9] ' Previous-error)
(Define-key Global-map [F9] ' Next-error)
;;( Set-default-font "9x15")
;;( Set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1")
(Set-default-font "10x20")
;;( Set-default-font "-outline-ðâëîìå-normal-r-normal-normal-14-*-96-96-c-*-gb2312")

;; Load Cedet
(load-file "~/.emacs.d/cedet-1.0pre6/common/cedet.el")
;;  Enabling various semantic minor modes. Semantic/install for more ideas.
;; Select one of the following:
;; * This enables the database and idle reparse engines
;;( Semantic-load-enable-minimum-features)
;; * This enables some tools useful for coding, such as summary mode
;; Imenu support, and the Semantic Navigator
;;( Semantic-load-enable-code-helpers)
;; * This enables even more coding tools such as the nascent IntelliSense mode
;; Decoration mode, and Stickyfunc mode (plus regular code helpers)
;;( Semantic-load-enable-guady-code-helpers)
;; * This turns on Which-func support (Plus all other code helpers)
(semantic-load-enable-excessive-code-helpers)
;; This is turns on modes of the aid in grammar writing and semantic tool
;;  Development. It does not enable any other features such as code
;; Helpers above.
(semantic-load-enable-semantic-debugging-helpers)

;; Configure semantic
(Setq semanticdb-project-roots (expand-file-name "/"))
(Defun my-indent-or-complete ()
(interactive)
(if (looking-at "//>") (Hippie-expand Nil) (Indent-for-tab-command))
)
(Define-key global-map [(Control tab)] ' My-indent-or-complete)
(AutoLoad ' senator-try-expand-semantic "Senator")
(Setq hippie-expand-try-functions-list ' (
Senator-try-expand-semantic
Try-expand-dabbrev
Try-expand-dabbrev-visible
Try-expand-dabbrev-all-buffers
Try-expand-dabbrev-from-kill
Try-expand-list
Try-expand-list-all-buffers
Try-expand-line
Try-expand-line-all-buffers
Try-complete-file-name-partially
Try-complete-file-name
Try-expand-whole-kill
))

(Define-key Global-map [(f4)] ' Speedbar-get-focus)
(Require ' Cc-mode)
(C-set-offset ' Inline-open 0)
;;( C-set-offset ' friend '-)
(C-set-offset ' Substatement-open 0)
(Defun My-c-mode-common-hook ()
(setq tab-width 8 indent-tabs-mode Nil)
(C-set-style "K&r")
;;; Hungry-delete and Auto-newline
(C-toggle-auto-hungry-state 1)
(Define-key C-mode-base-map [(Control/')] ' hs-toggle-hiding)
;; (Define-key C-mode-base-map [(return)] ' newline-and-indent)
;; (Define-key C-mode-base-map [(f6)] ' compile)
(Define-key c-mode-base-map [(Meta/')] ' C-indent-command)
;; (Define-key c-mode-base-map [(tab)] ' Hippie-expand)
(Define-key c-mode-base-map [(tab)] ' My-indent-or-complete)
(Define-key c-mode-base-map [(Meta/)] ' Semantic-ia-complete-symbol-menu)

(setq C-macro-shrink-window-flag T)
(setq c-macro-preprocessor "CPP")
(setq c-macro-cppflags "")
(setq C-macro-prompt-flag T)
(setq Hs-minor-mode T)
(setq Abbrev-mode T)
)
(Add-hook ' C-mode-common-hook ' My-c-mode-common-hook)
(Defun My-c++-mode-hook ()
(setq tab-width 8 indent-tabs-mode Nil)
;; (C-set-style "Stroustrup")
(C-set-style "K&r")
;; (Define-key C++-mode-map [F3] ' Replace-regexp)
)

(Add-to-list ' Load-path "~/.EMACS.D")

(Require ' Display-line-number)
;;( Load-library "Linum.el")
(Global-display-line-number-mode 1)
;;( SETQ display-line-number-mode-on T)
(Add-hook ' C-mode-hook ' Display-line-number-mode)
(Add-hook ' Cc-mode-hook ' Display-line-number-mode)

(Add-to-list ' Load-path "~/.emacs.d/ecb-2.40")
;;( Require ' ECB)
(Require ' ecb-autoloads)

;; For Gdb-many-window mode
(Require ' gud)
(setq gdb-many-windows T)
;;( SETQ Gud-tooltip-mode T)
;;( Load-library "Multi-gud.el")
;;( Load-library "Multi-gdb-ui.el")
(Add-hook ' Gdb-mode-hook ' (Lambda ()
(Gud-tooltip-mode 1)
(Define-key c-mode-base-map [F5] ' gud-go)
(Define-key c-mode-base-map [C-f5] ' Gud-run)
(Define-key c-mode-base-map [S-f5] ' Gud-cont)
(Define-key c-mode-base-map [F7] ' compile)
(Define-key C-mode-base-map [F8] ' Gud-print)
(Define-key c-mode-base-map [C-f8] ' Gud-pstar)
(Define-key C-mode-base-map [F9] ' Gud-break)
(Define-key c-mode-base-map [c-f9] ' Gud-remove)
(Define-key C-mode-base-map [F10] ' Gud-next)
(Define-key c-mode-base-map [C-F10] ' Gud-until)
(Define-key c-mode-base-map [S-F10] ' Gud-jump)
(Define-key C-mode-base-map [F11] ' Gud-step)
(Define-key c-mode-base-map [s-f11] ' Gud-finish)]

;; Form Toggle
(Require ' Wcy-swbuff)
;; Then can use <C-tab> and <C-S-kp-tab> to switch buffer.
(Define-key global-map (kbd "<C-tab>") ' Wcy-switch-buffer-forward ')
(Define-key global-map (kbd "<C-S-kp-tab>") ' Wcy-switch-buffer-backward ')
(setq wcy-switch-buffer-active-buffer-face ' highlight)
(setq wcy-switch-buffer-inactive-buffer-face ' secondary-selection)

;; Cscope in Emacs
(Add-to-list ' Load-path "~/.emacs.d/cscope-15.7a/contrib/xcscope")
(Require ' Xcscope)

;; Hotkey for Cscope
(Define-key Global-map [(Control F3)] ' Cscope-set-initial-directory)
(Define-key Global-map [(Control F4)] ' Cscope-unset-initial-directory)
(Define-key Global-map [(Control F5)] ' Cscope-find-this-symbol)
(Define-key Global-map [(Control F6)] ' cscope-find-global-definition)
(Define-key Global-map [(Control F7)]
' Cscope-find-global-definition-no-prompting)
(Define-key Global-map [(Control F8)] ' Cscope-pop-mark)
(Define-key Global-map [(Control F9)] ' Cscope-next-symbol)
(Define-key Global-map [(Control F10)] ' Cscope-next-file)
(Define-key Global-map [(Control F11)] ' Cscope-prev-symbol)
(Define-key Global-map [(Control F12)] ' Cscope-prev-file)
(Define-key Global-map [(Meta F9)] ' Cscope-display-buffer ')
(Define-key Global-map [(Meta F10)] ' Cscope-display-buffer-toggle ')
(Set-face-background ' Default "#334455")
(Set-face-foreground ' Default "wheat")
(set-cursor-color "White")
;;( Add-to-list ' Load-path "~/.emacs.d/color-theme-6.6.0")
;;( Require ' Color-theme)
;;( Color-theme-dark-blue)

(Custom-set-variables
;; Custom-set-variables is added by Custom.
;; If you are edit it by hand, your could mess it up and so is careful.
;; Your init file should contain only one such instance.
;; If there is more than one, the they won ' t work right.
' (Ecb-source-path (quote ("/home/zhouyi198631/linux")))
(custom-set-faces
;; Custom-set-faces is added by Custom.
;; If you are edit it by hand, your could mess it up and so is careful.
;; Your init file should contain only one such instance.
;; If there is more than one, the they won ' t work right.
)


;; Copy a row
(Defun copy-line (&optional Arg)
"Save current line into kill-ring without Mark"
(interactive "P")
((Beg (Line-beginning-position))
(End (Line-end-position Arg))
(Copy-region-as-kill Beg end))
)

;; Copy current Word
(Defun Copy-word (&optional Arg)
"Copy Words at point"
(interactive "P")
(Let ((Beg (Progn (looking-back "[a-za-z0-9]" 1) (Backward-word 1))
(End (Progn (Forward-word Arg)))
(Copy-region-as-kill Beg end))
)

;; Copy a paragraph
(Defun copy-paragraph (&optional Arg)
"Copy paragraphes at Point"
(interactive "P")
((Beg (Progn (backward-paragraph 1) (point))
(End (Progn (forward-paragraph Arg)))
(Copy-region-as-kill Beg end))
)

;; Copy a string
(Defun copy-string (&optional Arg)
"Copy a sequence of string into Kill-ring"
(interactive)
(setq onpoint (point))
(Let (
(Beg (Progn (Re-search-backward "[/t]" (line-beginning-position) 3 1)
(if (looking-at "[t]") (+ (point) 1) (point))
)
(End (Progn (Goto-char onpoint) (Re-search-forward "[t]" (line-end-position) 3 1)
(if (looking-back "[t]") (-(point) 1) (point))
)
)
(Copy-region-as-kill Beg end)
)
)

;; Shortcut keys
(setq X-select-enable-clipboard T)
(Global-set-key (kbd "C-c w") (quote Copy-word))
(Global-set-key (kbd "C-c L") (quote Copy-line))
(Global-set-key (kbd "C-c P") (quote copy-paragraph))
(Global-set-key (kbd "C-c S") (quote copy-string))

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.