What is wrong with the way I concatenate paths in Emacs elisp

I have a .dir-locals.el file in my project in which I am configuring my project for debugging using dap-debug in Emacs with debugpy.

I have this variant of the .dir-locals.el file that works just fine:

((nil . ((eval . (progn
                   (setq-local my-local-root (projectile-project-root))
                   (setq-local my-local-path (expand-file-name "linux-application/my_app" my-local-root))
                   (message "Project root is: %s" my-local-root)
                   (message "Concatenated path: %s" my-local-path)))
         (dap-debug-template-configurations
          . (("Docker Pytest Debug"
              :type "python"
              :request "attach"
              :hostName "localhost"
              :port 5678
              :name "Docker Pytest Debug"
              :pathMappings ((
                              ( :localRoot .  "/home/my_user/projects/our-gateway/linux-application/my_app")
                              ( :remoteRoot . "/usr/src/app/linux-application/my_app")
                              ))))))))

Now, to make things a bit more general, I would like to replace:

 ( :localRoot .  "/home/my_user/projects/our-gateway/linux-application/my_app")

With something like this:

( :localRoot . my-local-path)

but this does not work. When doing the change the debugger do not find the source code.

This makes me believe the path “my-local-path” is not the same as the string in my working variant. When I look at the print of the variable “my-local-path” in Emacs messages buffer it looks like it is the same though. I have also checked that they both are strings. The file .dir-local.el is in the folder /home/my_user/projects/our-gateway.

I have also tried to do the concatenation with “concat”, but that generates the same issue.

1

Thanks tripleee, you were correct. Here is my working file:

((nil . ((eval . (progn
               (setq-local my-local-root (projectile-project-root))
               (setq-local my-local-path (expand-file-name "linux-application/my_app" my-local-root))
               (message "Project root is: %s" my-local-root)
               (message "Concatenated path: %s" my-local-path)
               (setq dap-debug-template-configurations
                     `(("Docker Pytest Debug"
                        :type "python"
                        :request "attach"
                        :hostName "localhost"
                        :port 5678
                        :name "Docker Pytest Debug"
                        :pathMappings (((:localRoot . ,my-local-path)
                                        (:remoteRoot . "/usr/src/app/linux-application/my_app")))))))))))

So, the error was: “dap-debug-template-configurations is outside the eval so of course it doesn’t have access to the local variables you declared within it”.

Some comments on the piece of code (I am not that good at elisp, so pleas correct me if I am wrong):

  • “Docker Pytest Debug” is the name of the template you will see when you start the debugging in Emacs with M x dap-debug.
  • “attach” tells Emacs that it should attach to a remote debug session.
  • “port” is the port at which the debugger is listening for Emacs.
  • “LocalRoot” is the folder where the source code is located on the host running Emacs.
  • “remoteRoot” is the source code folder within the Docker container where, in my case, debugpy is running.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật