Emacs 모드:"명령을 사용하려고 시도 minibuffer 는 동안에 minibuffer"

StackOverflow https://stackoverflow.com/questions/812135

  •  03-07-2019
  •  | 
  •  

문제

시나리오:

  • 나는 입력하기 시작 M-x 는 명령을 입력하
  • 저장소에 저장되어야 emacs 창/버퍼 때문에 제가 실감 나는 명령을 실행하는 잘못된 창
  • 나는 입력하기 시작 M-x 다시 명령을 실행하려면 올바른 창에서

결과:나는 두려워한"명령을 사용하려고 시도 minibuffer 는 동안에 minibuffer"

이런 일이 나에게 하루에 여러 번을 사용하는 동안 emacs,그리고 단지에서 이 시나리오.이 행동은 매우 사용자는 적대(ref.모 및 의사 모드에서 The Humane Interface 에 의해 제프 라 스킨)

하는 방법이 있 사용자 지정 emacs 행동하도록 대신 이 오류는,그것은 단지 취소하는 첫 번째 minibuffer 으로 대체합니다.

도움이 되었습니까?

해결책

실제로 이 emacs"기능"는 적극적인 캐릭터가 기다리고 있습니다.나는 이것이 바로 응답하는 문제입니다.가장 가능성이 초점을 잃의 minibuffer 기 때문에 당신은 전환 windows 마우스로 아 minibuffer 명령입니다.그래서 때마다 당신은 초점을 잃고 마우스를 사용하여 minibuffer 삭제됩니다.을 확인합니다.그것은 나를 위해 일하고 그것의 방법보다 더 나은 재귀 minibuffers 는 두통을 일으키는 원인이 될 것입니다

http://trey-jackson.blogspot.com/2010/04/emacs-tip-36-abort-minibuffer-when.html

다른 팁

변수를 설정할 수 있습니다 enable-recursive-minibuffers, 해당 오류 메시지가 나타나는 것을 방지 할 수 있습니다. 그러나 그것은 미니 버퍼로 여러 호출을 가능하게합니다. 현재 미니 버퍼의 명령을 새 버퍼로 리디렉션하지는 않습니다. 당신은 이것을 시도 할 수 있지만, 원래의 행동이 아직 보류 중이기 때문에 더 혼란 스러울 것이라고 생각합니다 ...

M-x 묶여 있습니다 'execute-extended-command, 해당 명령에 대한 재 호스팅 (원본 버퍼 변경)은 계속해서 프로그래밍하는 것과 같습니다. 즉, 위치 X에서 서브 루틴을 호출하지만 완료되면 X로 돌아 오는 대신 Y로 돌아갑니다. 개인적으로 해결하는 것보다 더 많은 혼란이 열릴 것이라고 생각합니다. 그러나 나는 좌절감을 이해합니다 (그리고 같은 좌절감을 가진 다른 사람들을 알고 있습니다).

그런 사용자 정의가 있는지 확실하지 않지만 이것을 피하는 방법은 타격을 받고 있습니다. Ctrl 키-g 명령을 취소하기 위해 나는 미니 버퍼에 글을 쓰는 중에있었습니다.

첫 번째 대답은 당신이 원하는 것을 직접 제공하지 않기 때문에 실제 해결책을 제시 할 것이라고 생각했습니다. 이것이 내가 가진 것입니다.

(defvar my-execute-extended-command-source-buffer nil
  "var holding the buffer to which the extended-execute-command should apply")
(defvar in-my-execute-extended-command nil
  "internal use - indicates whether we're in a 'recursive edit' of sorts")
(defun my-execute-extended-command (command)
  "home-grown version of execute-extended-command that supports re-hosting the buffer"
  (interactive (list (if in-my-execute-extended-command
                   nil
                 (let ((in-my-execute-extended-command t))
                   (setq my-execute-extended-command-source-buffer (current-buffer))
                   (completing-read "My-x " obarray 'commandp t nil 'extended-command-history nil nil)))))
  (if in-my-execute-extended-command
      (progn (setq my-execute-extended-command-source-buffer (current-buffer))
             (select-window (minibuffer-window)))
    (switch-to-buffer my-execute-extended-command-source-buffer)
    (call-interactively (symbol-function (intern command)))))

나는 이것을 이런 식으로 테스트했다. 나는 그것을 열쇠에 묶었 다 (F10 내 경우 B/C는 잃고 싶지 않았습니다. M-x). 그런 다음 두 개의 창이 열린 상태에서 각각 다른 버퍼 (A 및 B)를 표시합니다.

  1. 버퍼 A를 표시하는 창에서 : F10 isearch-for
  2. 미니 버퍼에서 a를 보여주는 창으로 전환하십시오. C-x o
  3. B를 표시하는 창에서 B를 보여주는 B : C-x o
  4. 버퍼 B의 명령을 "다시 호스트"합니다. F10
  5. 이제 미니 버퍼로 돌아와 명령을 완성하십시오 ward RET

검색어를 입력하기 시작하면 검색이 버퍼 B에 적용되었습니다.

이것은 만 대체합니다 M-x 기능은 호출 된 명령이 아닙니다 M-x. 또한이 버전은 접두사 인수를 지원하지 않습니다.

바라건대 이것은 당신이 원하는 것입니다.

누구든지 다음을 개선 할 수 있습니까?

나는 새 미니 버퍼를 열기 전에 이전 미니 버퍼를 취소하기 위해 cw를 설정하고 싶다 ( cg cw와 같은).

지금까지 Trey에게 감사합니다.

(defun cancel-completing-read ()
  (if (> (minibuffer-depth) 0) (exit-minibuffer))
   (completing-read "My-x " obarray 'commandp t nil 'extended-command-history nil nil))

(defun cancel-and-execute-command (command)
  (interactive (list (cancel-completing-read)))
  (call-interactively (symbol-function (intern command))))

(global-set-key "\M-x" 'cancel-and-execute-command)

대신에 어떤 명령을 사용해야합니까? exit-minibuffer 위에?

난 노력 했어

keyboard-escape-quit
exit-minibuffer
keyboard-quit

여기에 간다 :

;; automatically cancel the minibuffer when you switch to it, to avoid
;; "attempted to use minibuffer" error.
;; cy was here

(provide 'cancel-minibuffer)

(defun cancel-minibuffer-first (sub-read &rest args)
    (let ((active (active-minibuffer-window)))
        (if active
                (progn
                    ;; we have to trampoline, since we're IN the minibuffer right now.
                    (apply 'run-at-time 0 nil sub-read args)
                    (abort-recursive-edit))
            (apply sub-read args))))

(advice-add 'read-from-minibuffer :around #'cancel-minibuffer-first)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top