Emacs 最大化和全屏的配置

仅供存放个人的配置文件,不要在本版发问。
kemean
帖子: 110
注册时间: 2007-03-06 22:58
送出感谢: 0
接收感谢: 1 次

Emacs 最大化和全屏的配置

#1

帖子 kemean » 2007-06-29 22:13

将以下代码加入.emacs:

代码: 全选

(global-set-key [f11] 'my-fullscreen)

;全屏
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0))
)

;最大化
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
)
;启动时最大化
(my-maximized)



代码: 全选

(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
)


应该改为:

代码: 全选


;该函数用于最大化,状态值为1说明最大化后不会被还原
;因为这里有两次最大化 (分别是水平和垂直)
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)
上次由 kemean 在 2007-08-05 22:02,总共编辑 3 次。
这些用户感谢了作者 kemean 于这个帖子:
zuriaake2011 (2012-09-02 2:29)
评价: 3.7%
kemean
帖子: 110
注册时间: 2007-03-06 22:58
送出感谢: 0
接收感谢: 1 次

再贴一下完整的配置

#2

帖子 kemean » 2007-06-29 22:18

再贴一下完整的配置,基本上是参照其它网友提供的改的:

代码: 全选

;插件路径
(add-to-list 'load-path "/home/share/myemacs")
(add-to-list 'load-path "/home/share/myemacs/ecb")
(add-to-list 'load-path "/home/share/myemacs/xcscope")
(add-to-list 'load-path "/home/share/myemacs/cedet/common")


;字体设置
(set-default-font "YaHeiConsolas-13")
(set-fontset-font "fontset-default"
                  'unicode '("YaHeiConsolas-13" . "unicode-bmp"))
(setq default-frame-alist
      (append '((font . "YaHeiConsolas-13")) default-frame-alist))


;解决emacs shell 乱码
(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);关闭customize窗口


;自定义按键
(global-set-key [f1] 'shell);F1进入Shell
(global-set-key [f5] 'gdb);F5调试程序
(setq compile-command "make -f Makefile")
(global-set-key [f7] 'do-compile);F7编译文件
(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
(global-set-key [f12] 'my-fullscreen);F12 全屏
(global-set-key (kbd "C-,") 'backward-page);文件首
(global-set-key (kbd "C-.") 'forward-page);文件尾


;普通设置
(setq inhibit-startup-message t);关闭起动时闪屏
(setq visible-bell t);关闭出错时的提示声
(setq make-backup-files nil);不产生备份文件
(setq default-major-mode 'text-mode);一打开就起用 text 模式
(global-font-lock-mode t);语法高亮
(auto-image-file-mode t);打开图片显示功能
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);显示列号
(show-paren-mode t);显示括号匹配
(display-time-mode 1);显示时间,格式如下
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(tool-bar-mode nil);去掉那个大大的工具栏
(scroll-bar-mode nil);去掉滚动条
;(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq mouse-yank-at-point t);支持中键粘贴
(transient-mark-mode t);允许临时设置标记
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq frame-title-format '("" buffer-file-name "@emacs" ));在标题栏显示buffer名称
(setq default-fill-column 80);默认显示 80列就换行


;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)


;非交互式编译
(defun do-compile ()
  "Save buffers and start compile"
  (interactive)
  (save-some-buffers t)
  (setq compilation-read-command nil)
  (compile compile-command)
  (setq compilation-read-command t))


;shell,gdb退出后,自动关闭该buffer
(add-hook 'shell-mode-hook 'mode-hook-func)
(add-hook 'gdb-mode-hook 'mode-hook-func)
(defun mode-hook-func  ()
  (set-process-sentinel (get-buffer-process (current-buffer))
         #'kill-buffer-on-exit))
(defun kill-buffer-on-exit (process state)
  (message "%s" state)
  (if (or
       (string-match "exited abnormally with code.*" state)
       (string-match "finished" state))
      (kill-buffer (current-buffer))))


;全屏
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0)))

;最大化
(defun my-maximized-horz ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun my-maximized-vert ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)


;加入会话功能
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
(load "desktop")
(desktop-save-mode)


;加入标签功能
(require 'tabbar)
(tabbar-mode)
;(global-set-key (kbd "") 'tabbar-backward-group)
;(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "C-`") 'tabbar-backward)
(global-set-key (kbd "C-<tab>") 'tabbar-forward)
;设置tabbar字体
(set-face-attribute 'tabbar-default-face
          nil :family "Tahoma")


;加入color-theme插件
(require 'color-theme)
(color-theme-classic)


;启动最大化
;(require 'maxframe)
;(setq mf-max-width 1018)
;(setq mf-max-height 730)
;(add-hook 'window-setup-hook 'maximize-frame t)


;加入xcscope插件
(require 'xcscope)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C/C++设定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;缩进策略
(defun my-indent-or-complete ()
  (interactive)
  (if (looking-at "\\>")
      (hippie-expand nil)
    (indent-for-tab-command)))
;补全优先级
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
      '(
   senator-try-expand-sematic
   try-expand-dabbrev
   try-expand-dabbrev-visible
   try-expand-dabbrev-all-buffers
   try-expand-dabbrev-from-kill
   try-complete-file-name-partially
   try-complete-file-name
   try-expand-all-abbrevs
   try-expand-list
   try-expand-line
   try-complete-lisp-symbol-partially
   try-complete-lisp-symbol))
;;;; CC-mode配置  http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;;;根据后缀判断所用的mode
;;;;注意:我在这里把.h关联到了c++-mode
(setq auto-mode-alist
      (append '(("\\.h$" . c++-mode)) auto-mode-alist))
;;;;我的C语言编辑策略
(defun my-c-mode-common-hook()
  (setq default-tab-width 4 indent-tabs-mode nil)
  (setq tab-width 4 indent-tabs-mode nil)
  (setq c-basic-offset 4)
  ;;; 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 [(f7)] 'do-compile)
  ;(define-key c-mode-base-map [(f8)] 'ff-get-other-file)
  (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)
;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
  (setq default-tab-width 4 indent-tabs-mode nil)
  (setq tab-width 4 indent-tabs-mode nil)
  (setq c-basic-offset 4)
  ;;(define-key c++-mode-map [f3] 'replace-regexp)
  (c-set-style "stroustrup"))
(add-hook 'c++-mode-hook 'my-c++-mode-hook)


;加入cedet插件
(add-hook 'texinfo-mode-hook (lambda () (require 'sb-texinfo)))
(require 'cedet)
(semantic-load-enable-code-helpers)
(autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
(autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t)
(define-key-after (lookup-key global-map [menu-bar tools])
  [speedbar]
  '("Speedbar" .
    speedbar-frame-mode)
  [calendar])
(global-set-key [f4] 'speedbar);F4打开/关闭speedbar
;;;;semantic /usr/include     
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
          (lambda ()
            (setq semanticdb-project-system-databases
                  (list (semanticdb-create-database
          semanticdb-new-database-class
          "/usr/include")))))
;project root path
(setq semanticdb-project-roots
      (list
       (expand-file-name "~/devel")))


;加入ecb插件
(require 'ecb)
;ecb设置
(require 'ecb-autoloads)
(setq ecb-auto-activate t
      ecb-tip-of-the-day nil
      inhibit-startup-message t
      ecb-auto-compatibility-check nil
      ecb-version-check nil)



(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.
 '(ecb-layout-window-sizes (quote (("left8" (0.20967741935483872 . 0.27586206896551724) (0.20967741935483872 . 0.2413793103448276) (0.20967741935483872 . 0.27586206896551724) (0.20967741935483872 . 0.1724137931034483)))))
 '(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)))
(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.
 )


;scroll other window
(global-set-key (kbd "C-c C-v") 'scroll-other-window)
(global-set-key (kbd "C-c C-b") 'scroll-other-window-down)

上次由 kemean 在 2007-08-05 22:10,总共编辑 2 次。
头像
linux白痴
帖子: 129
注册时间: 2006-12-11 10:24
来自: 湖北
送出感谢: 0
接收感谢: 0
联系:

#3

帖子 linux白痴 » 2007-06-30 16:26

直接性的看晕了
看来我太菜了!
meran
帖子: 2
注册时间: 2007-06-16 14:24
送出感谢: 0
接收感谢: 0

#4

帖子 meran » 2007-07-03 16:56

:shock:
kemean
帖子: 110
注册时间: 2007-03-06 22:58
送出感谢: 0
接收感谢: 1 次

最大化函数的修正。

#5

帖子 kemean » 2007-08-05 21:55

主要修正最大化函数,原有设置在BSD中工作不正常。

代码: 全选

;该函数用于全屏,状态值为2说明全屏后可以还原
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0)))



代码: 全选

;该函数用于最大化,状态值为1说明最大化后不会被还原
;因为这里有两次最大化 (分别是水平和垂直)
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)

奇怪的是,以前都用2时ubuntu下工作没出问题,换到BSD中问题就出现了。
因此,这里把值改为1就OK。
kemean
帖子: 110
注册时间: 2007-03-06 22:58
送出感谢: 0
接收感谢: 1 次

另外给一下tabbar字体设置的方法:

#6

帖子 kemean » 2007-08-05 21:58

另外给一下tabbar字体设置的方法:

代码: 全选

;加入标签功能
(require 'tabbar)
(tabbar-mode)
;(global-set-key (kbd "") 'tabbar-backward-group)
;(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "C-`") 'tabbar-backward)
(global-set-key (kbd "C-<tab>") 'tabbar-forward)


;设置tabbar字体-----说明,下面这段要加在tabbar之后。
(set-face-attribute 'tabbar-default-face
          nil :family "Tahoma")
kemean
帖子: 110
注册时间: 2007-03-06 22:58
送出感谢: 0
接收感谢: 1 次

#7

帖子 kemean » 2007-08-05 22:29

贴一下效果图:
图片

图片
头像
cheneymx
帖子: 159
注册时间: 2007-03-13 4:59
来自: Erlangen
送出感谢: 0
接收感谢: 0

#8

帖子 cheneymx » 2007-08-29 5:40

使用了你贴的最大化函数, 非常好使. 感谢..
huxl98
帖子: 1
注册时间: 2008-05-07 6:42
送出感谢: 0
接收感谢: 0

#9

帖子 huxl98 » 2008-05-07 6:43

太感谢了,一直想要让emacs在gnome下全屏,终于找到了,呵呵。
waterbow
帖子: 26
注册时间: 2008-06-11 17:03
送出感谢: 0
接收感谢: 0
联系:

#10

帖子 waterbow » 2008-07-09 10:07

最大化的函数不错,谢谢楼主阿
clxme
帖子: 11
注册时间: 2008-04-02 11:39
送出感谢: 0
接收感谢: 0

Re: Emacs 最大化和全屏的配置

#11

帖子 clxme » 2008-10-22 10:33

windows下我一直无法解决这个问题。郁闷....
有人知道怎么设置吗?
wenjianhn
帖子: 583
注册时间: 2008-10-15 10:49
来自: CS
送出感谢: 0
接收感谢: 0

Re:

#12

帖子 wenjianhn » 2009-08-13 14:56

补充点:

emacs -fs
一打开就全屏

代码: 全选

 _____________
< 呜呜buntu >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
头像
liuhengloveyou
帖子: 167
注册时间: 2007-10-18 17:37
来自: 深圳
送出感谢: 0
接收感谢: 0
联系:

Re: Emacs 最大化和全屏的配置

#13

帖子 liuhengloveyou » 2009-12-08 20:43

不错! 分享了你的全屏的配置..
wenjianhn
帖子: 583
注册时间: 2008-10-15 10:49
来自: CS
送出感谢: 0
接收感谢: 0

Re: Emacs 最大化和全屏的配置

#14

帖子 wenjianhn » 2010-06-03 11:35

emacs 23 用上面全屏配置显示不正常,minibuffer下会出现多余空行

这样能搞定:

代码: 全选

(defun my-fullscreen ()
        (interactive)
        (set-frame-parameter nil 'fullscreen
                             (if (frame-parameter nil 'fullscreen) nil 'fullboth)))

(run-with-idle-timer 0.1 nil 'my-fullscreen)
关键是最后一行的run-with-idle-timer

来源:
http://www.emacswiki.org/emacs/FullScreen#toc6

代码: 全选

 _____________
< 呜呜buntu >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
头像
pocoyo
论坛版主
帖子: 25878
注册时间: 2008-03-25 15:49
来自: 谁知道?
送出感谢: 5 次
接收感谢: 9 次
联系:

Re: Emacs 最大化和全屏的配置

#15

帖子 pocoyo » 2010-06-03 12:05

不爱全屏。
回复

回到 “个人配置文件存放点”