Stefan Kangas <stefankan...@gmail.com> writes:

> Org mode is still using the obsolete function `lisp-complete-symbol`,
> but that function has been obsoleted in favor of `completion-at-point`
> in version 24.4.  The attached diff is not meant to be installed, but to
> show where the problem is.
>
> The usual schedule for removing obsolete functions in Emacs would
> suggest that `lisp-complete-symbol` will be removed in Emacs 31.1, but
> we can't do that if Org mode is still using it.
>
> Could you please look into this?

AFAIK, the purpose of using lisp-complete-symbol is providing completion
inside special major mode for editing Org mode table formulas.
Org mode's table formulas can use Elisp sexps, which is why we want to
borrow completion from emacs-lisp-mode.

I am attaching tentative patch to make use of completion-at-point.
Let me know if you see something obviously wrong.

>From 8af89d490745b42475b7509c5ff18a49da0acd4b Mon Sep 17 00:00:00 2001
Message-ID: <8af89d490745b42475b7509c5ff18a49da0acd4b.1739637389.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Sat, 15 Feb 2025 17:35:33 +0100
Subject: [PATCH] org-table: Get rid of obsolete `lisp-complete-symbol'

* lisp/org-table.el (org-table-edit-formulas): Setup completion as in
emacs-lisp-mode.
(org-table-fedit-map):
(org-table-fedit-menu):
(org-table-fedit-post-command): Use `completion-at-point' instead of
`lisp-complete-symbol' as suggested in the obsoletion warning.
---
 lisp/org-table.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 0147fe4408..21286f59b0 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3326,8 +3326,8 @@ (defvar org-table-fedit-map
     (org-defkey map [(shift right)] 'org-table-fedit-ref-right)
     (org-defkey map [(meta up)]     'org-table-fedit-scroll-down)
     (org-defkey map [(meta down)]   'org-table-fedit-scroll)
-    (org-defkey map [(meta tab)]    'lisp-complete-symbol)
-    (org-defkey map "\M-\C-i"       'lisp-complete-symbol)
+    (org-defkey map [(meta tab)]    'completion-at-point)
+    (org-defkey map "\M-\C-i"       'completion-at-point)
     (org-defkey map [(tab)]	    'org-table-fedit-lisp-indent)
     (org-defkey map "\C-i"	    'org-table-fedit-lisp-indent)
     (org-defkey map "\C-c\C-r" 'org-table-fedit-toggle-ref-type)
@@ -3341,7 +3341,7 @@ (easy-menu-define org-table-fedit-menu org-table-fedit-map "Org Edit Formulas Me
     ["Abort" org-table-fedit-abort t]
     "--"
     ["Pretty-Print Lisp Formula" org-table-fedit-lisp-indent t]
-    ["Complete Lisp Symbol" lisp-complete-symbol t]
+    ["Complete Lisp Symbol" completion-at-point t]
     "--"
     "Shift Reference at Point"
     ["Up" org-table-fedit-ref-up t]
@@ -3400,6 +3400,9 @@ (defun org-table-edit-formulas ()
       (setq-local org-table--fedit-source source)
       (setq-local org-window-configuration wc)
       (setq-local org-selected-window sel-win)
+      ;; Use completion from `emacs-lisp-mode'
+      (add-hook 'completion-at-point-functions
+                #'elisp-completion-at-point nil 'local)
       (use-local-map org-table-fedit-map)
       (add-hook 'post-command-hook #'org-table-fedit-post-command t t)
       (setq startline (org-current-line))
@@ -3430,7 +3433,7 @@ (defun org-table-edit-formulas ()
 See menu for more commands.")))))
 
 (defun org-table-fedit-post-command ()
-  (when (not (memq this-command '(lisp-complete-symbol)))
+  (when (not (memq this-command '(lisp-complete-symbol completion-at-point)))
     (let ((win (selected-window)))
       (save-excursion
 	(ignore-errors (org-table-show-reference))
-- 
2.47.1

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to