From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: raman Newsgroups: gmane.emacs.devel Subject: Re: Reading major-mode name via completion? Date: Sun, 29 May 2016 15:18:13 -0700 Message-ID: References: <22346.23006.319783.759804@gargle.gargle.HOWL> <86a8j8bt1y.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1464560343 12044 80.91.229.3 (29 May 2016 22:19:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 May 2016 22:19:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 30 00:18:58 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b792v-0002r9-EE for ged-emacs-devel@m.gmane.org; Mon, 30 May 2016 00:18:57 +0200 Original-Received: from localhost ([::1]:57082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b792u-0003Cp-QA for ged-emacs-devel@m.gmane.org; Sun, 29 May 2016 18:18:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b792O-00039U-0G for emacs-devel@gnu.org; Sun, 29 May 2016 18:18:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b792I-0006ch-VC for emacs-devel@gnu.org; Sun, 29 May 2016 18:18:22 -0400 Original-Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:34195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b792I-0006cL-Nl for emacs-devel@gnu.org; Sun, 29 May 2016 18:18:18 -0400 Original-Received: by mail-pf0-x234.google.com with SMTP id 62so13804030pfd.1 for ; Sun, 29 May 2016 15:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=WuXalkOGGO/kUWdqnFZRxLWzNsvXOmQ72iFjgYgoqG8=; b=fiIq4cGTjrSed+IYvkxJf9GYtL9evl/S5odRmgK1VJlheJLo7/5lwZi8LynCEwCbpl pqjZIcxHZ2RpBbT99VNqjxNynqd6zRMS1nOoCXppv5cZGILuWCga/A9j8LVGMJIhkq0y nmit8VLX6iNn0xKXrsPQIY0JErB3JJ21LEV2VGw8bcdvWMGM1BuaVAyh4b7U7sNKbHqS CIex+GJZdDPTBpDFRwFzVGKCJp5toWF8Pwb+6GXqKD6IkMegqx3a1orPoemz27NYA00u qROCwptiwjBBnGxwTPkIrIaZAGx5lqlK8uBUx5qp/mrkolN9wRWCgW/8wWsFTI4F36xC mY+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=WuXalkOGGO/kUWdqnFZRxLWzNsvXOmQ72iFjgYgoqG8=; b=fenliCVcLINfNDna0MHgR3RlyZ/5E0lWGsv8Ap3EEwtjCnm2KGp2FtE2K8a62nfDg7 SekKYA7uN8fy4xo8LkrInQHlEDiZKiWSMnujEBp+GfcNjjRoucIhL6WvkW0JNKdfJAnt bwCjcOEcFrs7kFoqEsft+wmh7/lI/tL6ypcnsQeOrlW0fN/YGi6z3zjSttz4XUW2708x HOv+7KY/cNfracBd8sk0w42GAmFWk65lvAXxkRdVuf3ztV7/VoPqmtAE0JNr9X64ETgL GFOFL7H9yKYiXgOtOFnk5JlAIz5Aee8qj6E6PAIcW9osOCmP5SzWBthV9UniI6+Fn1iE AgbA== X-Gm-Message-State: ALyK8tKVgtmDx8Je0v5BO9owmNGDVOZPUJHpS6XG2/qiVluQ6rJqW82FY4TmGFhP2j9kQADt X-Received: by 10.98.34.25 with SMTP id i25mr40985677pfi.35.1464560297570; Sun, 29 May 2016 15:18:17 -0700 (PDT) Original-Received: from raman-glaptop2 (c-73-170-121-60.hsd1.ca.comcast.net. [73.170.121.60]) by smtp.gmail.com with ESMTPSA id t65sm19747836pfj.4.2016.05.29.15.18.14 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 29 May 2016 15:18:14 -0700 (PDT) In-Reply-To: <86a8j8bt1y.fsf@stephe-leake.org> (Stephen Leake's message of "Sun, 29 May 2016 13:47:05 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204137 Archived-At: Stephen Leake writes: Thanks! I cloned a small function out of customize-mode -- will attach it. 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\\'"))) (intern (completing-read "Major mode: " obarray nil t nil nil nil)))) > raman@google.com 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. --