0

多くの引数を使用してインタラクティブに関数を呼び出す必要があります (現時点では 7 ですが、大きくなる予定です)。すべての引数を連続して読み取ると、悪い経験が生じます。たとえば、ユーザーにクラス名の入力を求めています。クラス名は、それが含まれているかどうかに関係なく、パッケージによって完全修飾できます。そのため、ユーザーが完全に修飾されている必要があると考え、後でパッケージ名を提供するように依頼した場合、ユーザーが戻ってエラーを修正する方法はありません。

入力には、一度に処理するのが難しい側面もたくさんあります。たとえば、読み取り中の文字列に特定の文字が特定のパターンで表示されないようにする必要があります。入力の最後の項目で入力の検証に失敗した場合、ユーザーが手順全体をやり直すのはイライラします。 、一方、自由にカスタマイズできるバッファがあれば、変更が検証されず、既に送信された適切な値が保持されていない場合、変更をコミットするのを防ぐことができます。

tl;dr

カスタマイズ バッファを開き、ユーザー入力を対話的に呼び出される関数に読み込む方法を探しています。それを行う方法はありますか?

4

1 に答える 1

1

カスタマイズバッファ自体の代わりに、Emacsウィジェットライブラリを使用することをお勧めします。Emacs infoには、ウィジェットライブラリに関する優れたセクションがあります。を使用してemacsからアクセスできますC-h i m Widget RETまたは、ここからHTMLバージョンにアクセスできます。これは、マニュアルのウィジェットの例の抜粋です。

 (require 'widget)

 (eval-when-compile
   (require 'wid-edit))

 (defvar widget-example-repeat)

 (defun widget-example ()
   "Create the widgets from the Widget manual."
   (interactive)
   (switch-to-buffer "*Widget Example*")
   (kill-all-local-variables)
   (make-local-variable 'widget-example-repeat)
   (let ((inhibit-read-only t))
     (erase-buffer))
   (remove-overlays)
   (widget-insert "Here is some documentation.\n\n")
   (widget-create 'editable-field
         :size 13
         :format "Name: %v " ; Text after the field!
         "My Name")
   (widget-create 'menu-choice
         :tag "Choose"
         :value "This"
         :help-echo "Choose me, please!"
         :notify (lambda (widget &rest ignore)
               (message "%s is a good choice!"
                    (widget-value widget)))
         '(item :tag "This option" :value "This")
         '(choice-item "That option")
         '(editable-field :menu-tag "No option" "Thus option"))
   (widget-create 'editable-field
         :format "Address: %v"
         "Some Place\nIn some City\nSome country.")
   (widget-insert "\nSee also ")
   (widget-create 'link
         :notify (lambda (&rest ignore)
               (widget-value-set widget-example-repeat
                         '("En" "To" "Tre"))
               (widget-setup))
         "other work")
   (widget-insert
     " for more information.\n\nNumbers: count to three below\n")
   (setq widget-example-repeat
    (widget-create 'editable-list
               :entry-format "%i %d %v"
               :notify (lambda (widget &rest ignore)
                 (let ((old (widget-get widget
                            ':example-length))
                       (new (length (widget-value widget))))
                   (unless (eq old new)
                     (widget-put widget ':example-length new)
                     (message "You can count to %d." new))))
               :value '("One" "Eh, two?" "Five!")
               '(editable-field :value "three")))
   (widget-insert "\n\nSelect multiple:\n\n")
   (widget-create 'checkbox t)
   (widget-insert " This\n")
   (widget-create 'checkbox nil)
   (widget-insert " That\n")
   (widget-create 'checkbox
         :notify (lambda (&rest ignore) (message "Tickle"))
         t)
   (widget-insert " Thus\n\nSelect one:\n\n")
   (widget-create 'radio-button-choice
         :value "One"
         :notify (lambda (widget &rest ignore)
               (message "You selected %s"
                    (widget-value widget)))
         '(item "One") '(item "Another One.") '(item "A Final One."))
   (widget-insert "\n")
   (widget-create 'push-button
         :notify (lambda (&rest ignore)
               (if (= (length (widget-value widget-example-repeat))
                  3)
                   (message "Congratulation!")
                 (error "Three was the count!")))
         "Apply Form")
   (widget-insert " ")
   (widget-create 'push-button
         :notify (lambda (&rest ignore)
               (widget-example))
         "Reset Form")
   (widget-insert "\n")
   (use-local-map widget-keymap)
   (widget-setup))
于 2012-10-22T20:27:33.063 に答える