Здравствуй, ЛОР.
И снова я со своим имаксом. На этот раз мне хочется сохранения размеров и положения иксового окна при выходе и восстановления при старте.
Нашел нечто приблизительно похожее на требуемое, попробовал допилить, но не вышло, не знаю, как получать размеры фрейма:
(defun restore-saved-window-geom()
(unless (load "~/.emacs.d/framesize" t nil t)
(setq saved-window-size '(80 30)))
(nconc initial-frame-alist `((width . ,(car saved-window-size))
(height . ,(cadr saved-window-size))
)
)
(if (load "~/.emacs.d/framepos" t nil t)
(nconc initial-frame-alist `((left . ,(car saved-window-pos))
(top . , (cadr saved-window-pos))
)
)
)
)
(defun save-window-size-if-changed (&optional unused)
(let ((original-window-size `(,(frame-width) ,(frame-height))))
(unless (equal original-window-size saved-window-size)
(with-temp-buffer
(setq saved-window-size original-window-size)
(insert (concat "(setq saved-window-size '"
(prin1-to-string saved-window-size) ")"))
(write-file "~/.emacs.d/framesize")))))
(defun save-window-pos-if-changed (&optional unused)
; вот это и не работает
(let ((original-window-pos `(,(frame-left) ,(frame-top))))
(unless (equal original-window-pos saved-window-pos)
(with-temp-buffer
(setq saved-window-pos original-window-pos)
(insert (concat "(setq saved-window-pos '"
(prin1-to-string saved-window-pos) ")"))
(write-file "~/.emacs.d/framepos")))))
(when window-system
(restore-saved-window-geom)
(add-hook 'window-size-change-functions 'save-window-size-if-changed)
; (add-hook 'window-configuration-change-hook 'save-window-pos-if-changed)
)
(provide 'winsize)
Если кому интересно, то вот мой конфиг: http://github.com/FeiWongReed/emacs