[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading major-mode name via completion?

From: raman
Subject: Re: Reading major-mode name via completion?
Date: Sun, 29 May 2016 15:18:13 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux)

Stephen Leake <address@hidden> writes:

Thanks! I cloned a small function out of customize-mode -- will attach

I suspect my  code lets through  more cases,  
and  that your  predicate may also be tighter.
(defsubst soundscape-read-major-mode-name ()
  "Helper to read major-mode name with completion."
  (let ((completion-regexp-list '("-mode\\'")))
         (completing-read "Major mode: "
                          nil t nil nil nil))))

> address@hidden writes:
>> Is there a completion table that already exists in emacs that one
>> could pass to completing-read for reading in a major-mode name?
> I use this:
>    (completing-read
>     "mode: "
>     (apply-partially
>      #'completion-table-with-predicate
>      obarray
>      (lambda (sym) ;; predicate
>        (or (get sym 'derived-mode-parent) ;; most modes
>          (get sym 'custom-mode-group) ;; ada-mode
>          ;; FIXME: leaves out fundamental-mode, maybe others
>          ))
>      'strict)
>     nil ;; predicate
>     t ;; require-match
>     (symbol-name major-mode) ;; initial
>     history)
> as the FIXME: says, it leaves out some.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]