열등한 이맥스 리스프 모드에서 세션 간 기억


9

Emacs *ielm*가 세션 사이의 버퍼 히스토리를 기억하게 할 수는 없습니다 . 내가 알 수있는 한, 그러한 기록은 buffer-local 변수에 기록됩니다 comint-input-ring. 따라서 init 파일에 다음 표현식을 추가했습니다.

(setq desktop-locals-to-save
    (append desktop-locals-to-save
            '((comint-input-ring . 50))))

작동하지 않습니다. desktopEmacs가 desktop-globals-to-saveinit 파일에 추가 한 전역 변수를 기억하기 때문에 패키지가 작동 한다는 것을 알고 있습니다.

-

편집 : savehist작동하지 않습니다. comint-input-ring버퍼 로컬 변수 때문이라고 가정 합니다.


1
이제 데스크탑에서 작동하지 않는 이유를 확인할 시간이 없습니다. 그러나 savehist.el저장할 변수 목록에이 변수를 사용 하고 추가 할 수 있습니다 .
— Drew

고마워, 드류, 그러나 나는 savehist이미 그것에 대해 생각했다 . 내가 볼 수있는 한, 그것은 전역 변수에만 해당되는 반면 comint-input-ring버퍼 로컬입니다. 이제 나는 성공하지 않고 어쨌든 시도했다.
— Elena

경고 : 다음 해결책은 신성 모독입니다 !!! comint.el다음 두 줄의 코드에서 주석 처리 하십시오 : (put 'comint-input-ring 'permanent-local t)및 (make-local-variable 'comint-input-ring). 그런 다음, 추가 comint-input-ring로 desktop-locals-to-save. 마지막으로, 해당 파일을 다시 바이트 컴파일하고 Emacs를 다시 시작하여 최대한의 삶을 즐기십시오.
— lawlist December

답변:


5

버퍼가 종료 comint-input-ring될 때 전역 변수에 버퍼 로컬 값을 저장하고 *ielm*다음 위치에서 복원 할 수 있습니다 inferior-emacs-lisp-mode-hook.

;; global copy of the buffer-local variable
(defvar ielm-comint-input-ring nil)

(defun set-ielm-comint-input-ring ()
  ;; create a buffer-local binding of kill-buffer-hook
  (make-local-variable 'kill-buffer-hook)
  ;; save the value of comint-input-ring when this buffer is killed
  (add-hook 'kill-buffer-hook #'save-ielm-comint-input-ring)
  ;; restore saved value (if available)
  (when ielm-comint-input-ring
    (message "Restoring comint-input-ring...")
    (setq comint-input-ring ielm-comint-input-ring)))

(defun save-ielm-comint-input-ring ()
  (message "Saving comint-input-ring...")
  (setq ielm-comint-input-ring comint-input-ring))

(require 'ielm)
(add-hook 'inferior-emacs-lisp-mode-hook #'set-ielm-comint-input-ring)

이제 원하는 동작 을 추가 ielm-comint-input-ring하기 savehist-additional-variables위해 추가 할 수 있어야합니다 . (나는이 접근법을 테스트 desktop-locals-to-save했지만 당신 도 사용할 수 있어야합니다 .)


1
당신은 사용해야 LOCAL에 인수를 add-hook직접 호출하는 것이 아니라, make-local-variable에 kill-buffer-hook. 후자는 전역 적으로 후크에 콜백을 추가하려고 할 때 문제를 일으킬 수 있습니다.
— Phil

나는 이것이 inf-mongo또한 (또는 아마도 사용하는 다른 모드 comint) 효과가 있었음을 알게되어 매우 기뻤 습니다.
— Blake Miller
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.