目前采用下面的设置来保存桌面:(也尝试过很多其他保存的方法)
(setq desktop-dirname "~/.emacs.d/"
desktop-base-file-name "emacs.desktop"
desktop-base-lock-name "lock"
desktop-path (list desktop-dirname)
desktop-save t
desktop-files-not-to-save "^$" ;reload tramp paths
desktop-load-locked-desktop nil)
(desktop-save-mode t)
当再次打开emacs时,当前tab页面中的光标老是回到第一行,而不是退出emacs时的位置。
其它tab页面的光标位置正常,还是在原来的位置。
不解?
=========================
问题已解决,不是配置文件的问题,是窗口管理器的问题,如果使用平铺式窗口管理器(诸如:dwm、awesome、wmfs、i3等,我目前使用dwm)就会出现这个问题。采用浮动模式来打开emacs就没问题了。
我是在用openbox打开emacs时,发现无此现象,后来换用其它的浮动式窗口管理器均无此现象,才发现和窗口管理器有关,于是在dwm中采用浮动模式来打开emacs,问题解决。
至于原因,等有空再分析......
emacs为什么不能保存第一个tab文件中的光标的位置?(已解决)
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
emacs为什么不能保存第一个tab文件中的光标的位置?(已解决)
上次由 usbtopc 在 2011-04-09 10:49,总共编辑 1 次。
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
- sweating
- 帖子: 200
- 注册时间: 2009-02-07 18:01
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
我记得是和一个叫做插件相关
我的配置如下
(load "desktop")
(desktop-load-default)
(desktop-save-mode 1)
我的配置如下
(load "desktop")
(desktop-load-default)
(desktop-save-mode 1)
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
我也试过这个方法,也是不能保存第一个tab中文件的光标位置。其它tab的文件的光标位置都能正常保存,就是第一个tab上的文件光标老是回到第一行。sweating 写了:我记得是和一个叫做插件相关
我的配置如下
(load "desktop")
(desktop-load-default)
(desktop-save-mode 1)
你那边能保存吗?
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
目前,我只好每次退出emacs前,用鼠标点击一个空文件(事先建好),这个空文件的光标位置无所谓,这样再次打开emacs时,这个空文件会首先显示,而且光标位置在第一行,其它文件的光标的位置都正常。
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
为什么当前文件的光标位置无法保存呢?
当前文件:就是你退出emacs时正在编辑或浏览的那个文件,下次打开emacs时这个文件会首先显示,而且光标位置回到第一行,而不是你退出emacs时的位置(退出emacs时在200行,再次打开emacs时也应该在200行才对)。
当前文件:就是你退出emacs时正在编辑或浏览的那个文件,下次打开emacs时这个文件会首先显示,而且光标位置回到第一行,而不是你退出emacs时的位置(退出emacs时在200行,再次打开emacs时也应该在200行才对)。
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
我的配置文件:
代码: 全选
;;Emacs for Linux配置文件(~/.emacs)
;;所有插件都放在~/emacs目录里面
;;==========================================================
;;给Emacs添加Tab功能
;;==========================================================
;; 内容介绍:http://www.emacswiki.org/emacs/TabBarMode#toc4
;;选择里面的tabbar下载:http://sourceforge.net/projects/emhacks/files/
(add-to-list 'load-path
"~/emacs")
(require 'tabbar)
(tabbar-mode 1)
;;显示所有的buffers
(setq tabbar-buffer-groups-function
(lambda (buffer)
(list "All Buffers")))
;;隐藏特殊的buffers,主要是Emacs自己的buffers,大多以“*”开头
(setq tabbar-buffer-list-function
(lambda ()
(remove-if
(lambda(buffer)
(find (aref (buffer-name buffer) 0) " *"))
(buffer-list))))
(global-set-key (kbd "M-[") 'tabbar-backward-group)
(global-set-key (kbd "M-]") 'tabbar-forward-group)
(global-set-key (kbd "M-p") 'tabbar-backward-tab)
(global-set-key (kbd "M-n") 'tabbar-forward-tab)
(global-set-key [(control tab)] 'tabbar-forward-tab)
; 设置tab外观
(set-face-attribute 'tabbar-default-face nil
;:family "Tahoma"
:background "gray80"
:foreground "gray30"
:height 0.8)
;;==========================================================
;;保存打开的文件的历史记录(注意放在最前面)
;;==========================================================
;;(内容介绍和下载:http://www.emacswiki.org/emacs/EmacsSession)
(add-to-list 'load-path
"~/emacs")
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;;文件保存在什么位置
;(setq session-save-file "~/emacs/mysession")
;;==========================================================
;;配置cedet.el插件,设置C/C++环境
;;==========================================================
;;以下4行是为了兼容Windows,否则Windows下加载会出现找不到路径的问题
(add-to-list 'load-path "~/emacs/cedet/eieio")
(add-to-list 'load-path "~/emacs/cedet/semantic")
(add-to-list 'load-path "~/emacs/cedet/ede")
(add-to-list 'load-path "~/emacs/cedet/srecode")
(add-hook 'texinfo-mode-hook (lambda () (require 'sb-texinfo)))
(load-file "~/emacs/cedet/common/cedet.el")
(global-ede-mode 1)
(semantic-load-enable-minimum-features)
(semantic-load-enable-code-helpers)
(global-srecode-minor-mode 1)
;;代码折叠
;(require 'semantic-tag-folding nil 'noerror)
;(global-semantic-tag-folding-mode 1)
;;==========================================================
;;配置ecb插件,就是emacs code browser,代码浏览器
;;==========================================================
(add-to-list 'load-path "~/emacs/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)
;;隐藏和显示ECB窗口
(define-key global-map [(control f1)] 'ecb-hide-ecb-windows)
(define-key global-map [(control f2)] 'ecb-show-ecb-windows)
;;使某一ecb窗口最大化
(define-key global-map "\C-c1" 'ecb-maximize-window-directories)
(define-key global-map "\C-c2" 'ecb-maximize-window-sources)
(define-key global-map "\C-c3" 'ecb-maximize-window-methods)
(define-key global-map "\C-c4" 'ecb-maximize-window-history)
;;恢复原始窗口布局
(define-key global-map "\C-c0" 'ecb-restore-default-window-sizes)
;;==========================================================
;;系统自动生成的内容,一般都可以通过“选项”来设置,之后保存选项即可(推荐)
;;==========================================================
(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.
'(column-number-mode t)
'(display-time-mode t)
'(ecb-directories-general-face (quote ecb-default-general-face))
'(ecb-layout-window-sizes (quote (("right1" (ecb-directories-buffer-name 0.35135135135135137 . 0.2894736842105263) (ecb-sources-buffer-name 0.35135135135135137 . 0.34210526315789475) (ecb-methods-buffer-name 0.35135135135135137 . 0.34210526315789475)))))
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1))
'(global-semantic-decoration-mode t nil (semantic-decorate-mode))
'(global-semantic-highlight-func-mode t nil (semantic-util-modes))
'(newsticker-html-renderer (quote newsticker-htmlr-render))
'(newsticker-url-list-defaults nil)
'(scroll-bar-mode nil)
'(session-use-package t nil (session))
'(show-paren-mode t)
'(size-indication-mode t)
'(tabbar-cycling-scope (quote tabs))
'(tool-bar-mode nil))
(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.
'(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal :foundry "unknown" :family "DejaVu Sans")))))
;;==========================================================
;;代码自动完成
;;下载:http://cx4a.org/software/auto-complete/
;;最新:https://github.com/m2ym/auto-complete
;;==========================================================
(add-to-list 'load-path "~/emacs/auto-complete-1.3.1")
(require 'auto-complete-config)
(require 'auto-complete)
(global-auto-complete-mode t)
(ac-config-default)
(global-set-key [M-/] 'auto-complete)
;;==========================================================
;;显示行号(line-num.el)
;;内容介绍及下载:http://www.emacswiki.org/cgi-bin/emacs-de/LineNumbers
(global-linum-mode t)
(setq linum-format " %3d") ;;设置行号占用的宽度,否则行号显示会压线
;;==========================================================
;; 高亮当前行:hi-line.el
;;==========================================================
(require 'hl-line)
(global-hl-line-mode t)
;;=========================================================
;;cscope源代码浏览工具
;;=========================================================
(add-to-list 'load-path "~/emacs")
(require 'xcscope)
;;==========================================================
;;杂项
;;==========================================================
;;修改标题栏,显示buffer的名字
(setq frame-title-format "%f")
;;去掉终端响铃
(setq visible-bell t)
;;闪屏报警
(setq visible-bell t)
;; 设置行间距(像素)
(setq-default line-spacing 2)
;;启动时自动打开上次打开过的文件
;(desktop-save-mode 1)
;;用y/n代替yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;;允许emacs和外部其他程序粘贴
(setq x-select-enable-clipboard t)
;;光标显示为一竖线
(setq-default cursor-type 'bar)
;;语言风格
(defun program-mode()
(setq tab-width 8 indent-tabs-mode nil)
(c-toggle-auto-hungry-state 1)
(c-set-style "stroustrup"))
(add-hook 'c-mode-common-hook 'program-mode)
(add-hook 'c++-mode-common-hook 'program-mode)
;;绑定自动缩进到回车键
(global-set-key "\r" 'align-newline-and-indent)
;;页面平滑滚动, scroll-margin 3 靠近屏幕边沿3行时开始滚动,可以很好的看到上下文。
(setq scroll-margin 3
scroll-conservatively 10000)
;;鼠标指针规避光标
;(mouse-avoidance-mode 'animate)
;;使用X剪贴板(注意:和其他编辑器拷贝粘贴时容易出现乱码)
;(setq x-select-enable-clipboard t)
;;设定剪贴板内容格式 适应Firefox
;(set-clipboard-coding-system 'ctext)
;;保存上次光标所在的位置
(require 'saveplace)
(setq-default save-place t)
;; 最大化窗口
(require 'maxframe)
(add-hook 'window-setup-hook 'maximize-frame t)
;; 更丰富的高亮
(require 'generic-x)
;;PC格式的选择模式(选择后输入新的字符会覆盖被选择的内容)
(pc-selection-mode)
;;设置tab为4个空格的宽度,而不是原来的2
(setq c-basic-offset 4)
(setq default-tab-width 4)
;;显示日期
(setq display-time-day-and-date t)
(display-time)
;;显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-use-mail-icon t)
(setq display-time-interval 10)
;;==========================================================
;;颜色设置
;;相关内容:http://www.nongnu.org/color-theme/
;;==========================================================
(add-to-list 'load-path "~/emacs/color-theme-6.6.0")
(require 'color-theme)
(color-theme-initialize)
(setq color-theme-is-global t)
;(color-theme-robin-hood)
;(color-theme-matrix)
;(color-theme-classic)
;(color-theme-aliceblue)
;(color-theme-snowish)
;(color-theme-wheat)
;(color-theme-vim-colors)
;(color-theme-comidia)
;(color-theme-arjen)
;(color-theme-bharadwaj)
;;============================================================
;;设置全局快捷键
;;============================================================
;; F1:最大化当前buffer
(global-set-key [(f1)] 'delete-other-windows)
;; F2:切换到dired模式
(global-set-key [(f2)] 'dired)
;; F3:执行shell
(global-set-key [(f3)] 'shell)
;; F4:关闭buffer
(global-set-key [(f4)] 'kill-buffer-and-window)
;; F5:打开speedbar
(global-set-key [(f5)] 'speedbar)
;; F6:跳转到另一个窗口
(global-set-key [(f6)] 'other-window)
;; F7:编译
(global-set-key [(f7)] 'compile)
;;设置编译命令为make
(setq compile-command "make")
;; F9:gdb
(global-set-key [(f9)] 'gdb)
;; F10: gdb:next
(global-set-key [(f10)] 'gud-next)
;; F11::gdb:step
(global-set-key [(f11)] 'gud-step)
;;F12:函数自动跳转
(global-set-key [f12] 'semantic-ia-fast-jump)
;;============================================================
;;保存桌面
(setq desktop-dirname "~/.emacs.d/"
desktop-base-file-name "emacs.desktop"
desktop-base-lock-name "lock"
desktop-path (list desktop-dirname)
desktop-save t
desktop-files-not-to-save "^$" ;reload tramp paths
desktop-load-locked-desktop nil)
(desktop-save-mode t)
;;============================================================
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
- sweating
- 帖子: 200
- 注册时间: 2009-02-07 18:01
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
(desktop-save-mode t)的t改为1看看
在(desktop-save-mode 1)前面这句加上:(desktop-load-default)
(desktop-save-mode &optional ARG)
Toggle desktop saving mode.
With numeric ARG, turn desktop saving on if ARG is positive
numeric ARG
positive
所以我猜测为1
desktop-files-not-to-save这个变量我把握不准g,可能可以考虑去掉这个变量
我的这个变量的值是"\\(^/[^/:]*:\\|(ftp)$\\)"
在(desktop-save-mode 1)前面这句加上:(desktop-load-default)
(desktop-save-mode &optional ARG)
Toggle desktop saving mode.
With numeric ARG, turn desktop saving on if ARG is positive
numeric ARG
positive
所以我猜测为1
desktop-files-not-to-save这个变量我把握不准g,可能可以考虑去掉这个变量
我的这个变量的值是"\\(^/[^/:]*:\\|(ftp)$\\)"
-
- 帖子: 96
- 注册时间: 2009-06-30 23:05
Re: emacs为什么不能保存第一个tab文件中的光标的位置?
谢谢楼上的兄弟们,目前问题已解决,不是配置文件的问题,是窗口管理器的问题,如果使用平铺式窗口管理器就会出现这个问题。采用浮动模式来打开emacs就没问题了。
裸跑X可能是最后的选择......
目前使用dwm-plus: http://code.google.com/p/dwm-plus/
目前使用dwm-plus: http://code.google.com/p/dwm-plus/