From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Dev workflow in Emacs with containers Date: Sun, 1 Dec 2024 16:41:24 +0700 Message-ID: References: <87h67qnmae.fsf@k-7.ch> <874j3oa8gm.fsf@k-7.ch> Mime-Version: 1.0 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="34708"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Users list for the GNU Emacs text editor To: =?UTF-8?Q?S=C3=A9bastien_Gendre?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 01 10:42:16 2024 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 1tHgT2-0008q1-KC for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 01 Dec 2024 10:42:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHgST-0001Y5-VM; Sun, 01 Dec 2024 04:41:43 -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 1tHgSS-0001Xx-4G for help-gnu-emacs@gnu.org; Sun, 01 Dec 2024 04:41:40 -0500 Original-Received: from mail-vk1-xa2e.google.com ([2607:f8b0:4864:20::a2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHgSQ-0004F9-CJ for help-gnu-emacs@gnu.org; Sun, 01 Dec 2024 04:41:39 -0500 Original-Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-51533f41c94so750615e0c.0 for ; Sun, 01 Dec 2024 01:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733046097; x=1733650897; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eoA9msbr4QyVPnTGCqFB0FPKj9Y/oZCoz/r6SbniXuA=; b=Ru+M4hSIpL3ipMxFwq6ihf3Mzne6PvCyS5O/ekMFA0d4d/4bjAB//xrCiau9U5ISB4 iLXZOxuN2VaQzpRXnxWArAvQj5hnjFmx3l4eX8HUPPe3g+j0sLhZcLBrAe79mu5KBO8y B7CI4HZbAo5j4uHLJ6+IsOV2va+P0r2u4q848T6UnHGw/Pfms9OqbSiwmu7Xy5cAZTew hoeS98ebodnpUaaxl1zWT34ghCA9SNx0fHacJkDhYzqSFdwmvI3gVbIc5jqWX+zRg1lJ YWafurZIqln1H/iFX1/7BQ96HqIrYeFjgpgw0tcWw1yIHLLikX1gmEMGlHrBsmwHR4/Z 27cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733046097; x=1733650897; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eoA9msbr4QyVPnTGCqFB0FPKj9Y/oZCoz/r6SbniXuA=; b=dW4Svtlu9CXfbRKRxmRFPB8Z/v6qFRlidOzw8DNIGZLnNoHJuYH0W0pGiBJqqjCrh/ OgSUSD3PMBr/I3UahUoMqZ25pnLRFDy860ZpO4TmevCAAw+luLfjG9wur7XfYzjxHyfB /G36dhGlUc0s7GBp5Fs59NgN6oAl7Q7of3VxpShPKNoArwPvveeNm9wQp5CZAqx1tF3M 6Edm/MuMTbk51YidIQjck5gvRptDKgItpp6U2nWMo+MirTjIY0Fc4e/0MoRKGe809xAy nLiCQ8rP7+X0GUEt3tvFsiZDgu9SgqqQuOybOZ+pyWozyBD91xsY5I8W3Ic9K7PytDI2 KpkA== X-Gm-Message-State: AOJu0Yw4nQBmkORCgAhjCg90TZJGAvpCgMePQQ4aScZZrnQBofQXsMqT uNHwEclF1s9OIb1P5zY/gaQ/iXb4utiuIp0Jvw3B0paqFwD5rJyV24c9EFKPne24q7bDUy+QMvr FjH1zmkmrr/xf3TtIERPOA8tBByKa64WJmDY= X-Gm-Gg: ASbGncvWUykWEWcjuAVX7bpmWi06VpB00Cok9gzkBTiuahst0A72Rq5j9rOl/5essBf AJ7gZc0BhIv1lt9Wsmj9C3njGOzxg2QA= X-Google-Smtp-Source: AGHT+IHIME7B6F3fpvU3shP3q8EdMCE9kppcB+fvkNHj+fNnDc/62Ykk7Bkj62F6IbC7jwNd3D4uB2ubg+W3dnY3y9s= X-Received: by 2002:a05:6102:d87:b0:4ad:5c22:8412 with SMTP id ada2fe7eead31-4af4493e6d1mr23517386137.17.1733046096804; Sun, 01 Dec 2024 01:41:36 -0800 (PST) In-Reply-To: <874j3oa8gm.fsf@k-7.ch> Received-SPF: pass client-ip=2607:f8b0:4864:20::a2e; envelope-from=yurivkhan@gmail.com; helo=mail-vk1-xa2e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:148475 Archived-At: On Sun, 1 Dec 2024 at 01:21, S=C3=A9bastien Gendre wrote: > Seems a good way to do it. > > I haven't think about the language server. > How do you configure the container ? I install the language server in the same image that is used for building. This way, it has access to the same version of the standard library as the compiler does. If the project is set up to use system-packaged libraries, I install them in the same image. I bind-mount the sources and vendored third-party libraries. This way, I do not need to rebuild the image whenever they change. All this taken together ensures that (1) the language server sees the same sources and libraries that the compiler sees, and (2) I don=E2=80=99t need to install the same libraries on my host machine, which would defeat the point of dockerization. Another thing to look out for is where the language server caches its data. This should also be bind-mounted so that it persists between sessions. > > Where practical, I prefer to mount my volumes at the same paths in the > > container as locally, this simplifies the mapping a lot. But in some > > cases I hook =E2=80=98compilation-filter=E2=80=99 to a function that re= places > > prefixes. > > I'm very curious about your compilation filter. Can you share it ? As I said, mounting in matching paths is a lot simpler. Suppose I have the project root at /home/me/work/project on the host, but I mount it at /mnt/project in the container. The compiler will report its messages with the file names starting with /mnt/project. Then when I instruct Emacs to go to the error location, it will not find the file. It may ask me for assistance. So I have this somewhere in my load-path: ;; yk-compile.el (defvar yk-compilation-filter-alist nil "List of (REGEXP REPLACEMENT) to apply to compilation messages.") (defun yk-compilation-filter () "Apply replacements to compilation messages." (save-excursion (pcase-dolist (`(,regexp ,replacement) yk-compilation-filter-alist) (goto-char compilation-filter-start) (beginning-of-line) (while (re-search-forward regexp nil t) (replace-match replacement nil nil))))) (provide 'yk-compile) (this is probably not the most efficient way to do it, but it works for me)= . In the project root, I have a .dir-locals.el that sets up the replacements for this project: ((nil . ((yk-compilation-filter-alist . (("/mnt/project/" "/home/me/work/project/")))))) (Now that I think about it, I could probably achieve a similar effect using the =E2=80=98compilation-transform-file-match-alist=E2=80=99 variable= , except that it only helps with the issue of *jumping* to error location and not solving the *display* of file paths.) Additionally, with sources mounted in a path different from the host, the language server will also talk in terms of container paths. It will expect paths starting with =E2=80=98/mnt/project=E2=80=99 in the textDocument/didOpen notifications, and report that path in its textDocument/references responses. clangd happens to have a path mapping feature which is specified in its command line. My only motivation for mounting the sources in a path different from the host is that I want to have multiple working copies of the project on the host, so that I could work with multiple feature branches at the same time; and mounting them in the same place in the container allows me to speed up compilation using ccache. If compilation time is not an issue, I much prefer the ease of transparent paths.