From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sami@hamb.se Newsgroups: gmane.emacs.help Subject: Eglot code-action organise imports Date: Fri, 18 Nov 2022 09:42:47 +0100 Message-ID: <25D6F830-1298-4B4F-AA9C-51173E5F2900@hamb.se> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.81\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12522"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 09:43:35 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovwyF-00035e-9p for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 09:43:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovwxp-0005hx-91; Fri, 18 Nov 2022 03:43:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovwxm-0005cs-HD for help-gnu-emacs@gnu.org; Fri, 18 Nov 2022 03:43:06 -0500 Original-Received: from pv50p00im-zteg10021401.me.com ([17.58.6.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovwxk-0000Mt-Le for help-gnu-emacs@gnu.org; Fri, 18 Nov 2022 03:43:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hamb.se; s=sig1; t=1668760981; bh=1LrDiRYVMwIlql2OWl3wWXStI5N5dqWpDBTzAqWZbPY=; h=From:Content-Type:Mime-Version:Subject:Message-Id:Date:To; b=JSDgI9nHCG3rQVZjXb9UzErj1KZjPuh8xdQs/zpNw4Je8kAR+LXkkEgay9TqLDp8Z nIsITkvSqBLjWC8YHPmtHQgqKYHm1AMnrJYD41DZhAqY/2MCX9eej4f1I/Mb6wSB9N oxOYkAleRMJxbh5l2MIkASNwJLgRDug1l8jfimwvvQLAJtr0TdUBMFarIu62vv9kIy ma0f81gPPtsORRZpwjexZJCiggxPHNz1I4gMwmbkul2Qi7drajULfthmG8ME6lBwwf oIahKTKZXCqmxDaJPDVuO6438OlCoffI9XR4bhuQMFLJW87AYRSJS6+UWhuhnxKgJ4 VC1ww5vqs5WqA== Original-Received: from smtpclient.apple (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10021401.me.com (Postfix) with ESMTPSA id 8DCA88E0939 for ; Fri, 18 Nov 2022 08:42:59 +0000 (UTC) X-Mailer: Apple Mail (2.3731.300.81) X-Proofpoint-ORIG-GUID: P_lY6GIAvU_qwD91Hl-FpAME4iI2KG91 X-Proofpoint-GUID: P_lY6GIAvU_qwD91Hl-FpAME4iI2KG91 X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.11.64.514.0000000_definitions?= =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2022-02-23?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=684 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 spamscore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2211180054 Received-SPF: pass client-ip=17.58.6.47; envelope-from=sami@hamb.se; helo=pv50p00im-zteg10021401.me.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, HTML_OBFUSCATE_05_10=0.26, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141036 Archived-At: Hi all, I=E2=80=99m trying to get the code action of organize imports to work = with before-save-hook. Specifically for go-mode. I=E2=80=99ve been searching around and found a couple of issues later = linking to a solution similar to this: (defun sami/eglot-organize-imports () (call-interactively 'eglot-code-action-organize-imports)) (defun sami/before-saving-go () (add-hook 'before-save-hook #'eglot-format-buffer -10 t) (add-hook 'before-save-hook #'sami/eglot-organize-imports nil t)) (add-hook 'go-mode-hook #'sami/before-saving-go) Problem seems to be, running the function =E2=80=9Ceglot-code-actions=E2=80= =9D and selecting =E2=80=9COrganize imports=E2=80=9D works fine, but = running the stand-alone function of = =E2=80=9Ceglot-code-action-organize-imports=E2=80=9D does not yield = anything. Test case: In any go file, add something like fmt.Println(=E2=80=9Chello=E2=80=9D) = imports the package fmt automatically, deleting or commenting the line = does not delete the imported package fmt. = =E2=80=9Ceglot-code-action-organize-imports=E2=80=9D does not delete the = imported package fmt. Running the function =E2=80=9Ceglot-code-actions=E2=80= =9D and selecting =E2=80=9COrganize imports=E2=80=9D DOES deletes the = package fmt from imports. There are no errors in *Messages* nor in *EGLOT (testing/(go-mode)) = events*=20 Br Sami