Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Liu Hui
Jack Kamm 于2023年12月30日周六 06:20写道: > > Liu Hui writes: > > > But it is indeed possible that two sessions are inconsistent, if users > > intend to have different org-babel-python-command and > > python-shell-interpreter, which are used by > > `org-babel-python-

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-09 Thread Liu Hui
Ihor Radchenko 于2023年12月9日周六 18:29写道: > > Liu Hui writes: > > >> 2. Check the new variable and attempt to run > >>`org-babel--associate-session' in org-src-mode definition. > > > > I think associating the edit buffer with some session doesn't

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-08 Thread Liu Hui
Ihor Radchenko 于2023年12月8日周五 21:06写道: > > Liu Hui writes: > > >> What about displaying a yes/no query about starting a new session when > >> there is none? > > > > I think it is OK. I can add an option to allow users to disable the > > query. WDYT? &g

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-08 Thread Liu Hui
Ihor Radchenko 于2023年12月7日周四 23:16写道: > > Liu Hui writes: > > > Ihor Radchenko 于2023年12月7日周四 18:33写道: > > > >> > +(defun org-babel-edit-prep:python (info) > >> > + "Set Python shell in Org edit buffer according to INFO." &

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-07 Thread Liu Hui
Ihor Radchenko 于2023年12月7日周四 18:33写道: > > +(defun org-babel-edit-prep:python (info) > > + "Set Python shell in Org edit buffer according to INFO." > > + (let ((session (cdr (assq :session (nth 2 info) > > +(when (and session (not (string= session "none"))) > > + (setq-local

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-06 Thread Liu Hui
Ihor Radchenko 于2023年12月6日周三 21:20写道: > > Liu Hui writes: > > >> Makes sense. > >> I think we may drop a note about this new feature in ORG-NEWS. > > > > Thanks, I have added it in the attached patch. > > ... > > +When editing a Pyt

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-05 Thread Liu Hui
Ihor Radchenko 于2023年12月5日周二 19:48写道: > > Liu Hui writes: > > > When editing python src block using C-c ', the python shell is not set > > in Org edit buffer according to the :session header argument of the > > block. Consequently, commands such as python-shell-send-re

[PATCH] Set Python shell in Org edit buffer

2023-12-05 Thread Liu Hui
it is safe to remove it and related stuffs to avoid confusion. Best, Liu Hui From c8b9c174cf643bd625cedc311d2604e6fc3bb83a Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Tue, 5 Dec 2023 11:40:38 +0800 Subject: [PATCH] Set Python shell in Org edit buffer * lisp/ob-python.el (org-babel-edit

Re: [BUG] [PATCH] Add yank-media and DND handler [9.6.7 (9.6.7-g6eb773 @ /home/viz/lib/emacs/straight/build/org/)]

2023-10-11 Thread Liu Hui
Visuwesh 于2023年10月11日周三 23:36写道: > >> + (caddr (read-multiple-choice > >> + "What to do with dropped file?" > >> + '((?a "attach" attach) > >> + (?o "open" open) > >> + (?f "insert file: link" file-link > > > > The dialog box is shown in the center of frame and I find it a little > >

Re: [BUG] [PATCH] Add yank-media and DND handler [9.6.7 (9.6.7-g6eb773 @ /home/viz/lib/emacs/straight/build/org/)]

2023-10-11 Thread Liu Hui
Hi, Thanks for your work. I have two minor suggestions about the patch. > + (`file-link > + (let ((filename (dnd-get-local-file-name url))) > + (insert (org-link-make-string (concat "file:" filename I think it is better to abbreviate the file name for file-link, so it would be

Re: [BUG] [PATCH] Add yank-media and DND handler [9.6.7 (9.6.7-g6eb773 @ /home/viz/lib/emacs/straight/build/org/)]

2023-10-01 Thread Liu Hui
Visuwesh 于2023年10月1日周日 22:28写道: > Do you think asking during the time of drop > would be a viable option too? I'm thinking of adding the defcustom > org-dnd-default-method with options such as > > . attach -- as implemented here > . open -- open file > . file-link -- insert file

Re: [BUG] [PATCH] Add yank-media and DND handler [9.6.7 (9.6.7-g6eb773 @ /home/viz/lib/emacs/straight/build/org/)]

2023-09-29 Thread Liu Hui
Hi, 在 2023/9/27 16:29, Visuwesh 写道: > +*** Files and images can be attached by dropping onto Emacs > + > +Attachment method other than ~org-attach-method~ for dropped files can > +be specified using ~org-dnd-default-attach-method~. > +(defcustom org-dnd-default-attach-method nil > + "Default

[PATCH] Fix docstring of `org-at-timestamp-p'

2023-08-23 Thread Liu Hui
5: hours, if any group 6: minutes, if any but for timestamps like <2023-08-23 Wed>, (when (org-at-timestamp-p) (match-string 2)) will return the year 2023 instead of the month. This patch corrects the group numbers. From a3c31e4f8f40202fcef61fc7c4b16acaf006e24f Mon Sep 17 00:00:00 2001 Fro

Re: [PATCH] ob-python results handling for dicts, dataframes, arrays, and plots

2023-08-21 Thread Liu Hui
> Thanks for reporting these misbehaving examples. I think the root of the > problem is `org-babel-script-escape', which is too aggressive in > recursively converting strings to lists. We may need to rewrite our own > implementation for ob-python. > > Also, I agree that moving the python code to

Re: [PATCH] ob-python results handling for dicts, dataframes, arrays, and plots

2023-08-20 Thread Liu Hui
> > Here we can use '{}'.format(df.index.name) to show the name of index > > Patch has been updated to print the index name when it is non-None. Thanks! It would be nice to also support MultiIndex names using `result.index.names', e.g. #+begin_src python :results table import numpy as np import

Re: [PATCH] ob-python results handling for dicts, dataframes, arrays, and plots

2023-08-16 Thread Liu Hui
Hi, Thank you for the patch! > Next, for numpy arrays and pandas dataframes/series: these are > converted to tables, for example: > > #+begin_src python > import pandas as pd > import numpy as np > > return pd.DataFrame(np.array([[1,2,3],[4,5,6]]), >

Re: [PATCH] ob-python: Fix async evaluation

2023-07-13 Thread Liu Hui
. From 4c552eb4eec5d84727775645cdf41acebd7fd1da Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Wed, 12 Jul 2023 18:07:06 +0800 Subject: [PATCH] ob-python: Fix async evaluation * lisp/ob-python.el (org-babel-python-async-evaluate-session): Bind `python-shell-buffer-name' inside the temp buffer. * testing/lisp/t

Re: [PATCH] ob-python: Fix async evaluation

2023-07-12 Thread Liu Hui
Jack Kamm 于2023年7月12日周三 12:51写道: > The patch looks good, but it would be nice to include a unit test as > well -- could you update the patch to include one, Liu Hui? OK, I have added a test to the patch. From 56fd5e05bc7dc82fb825416100e75663a520 Mon Sep 17 00:00:00 2001 From: Liu Hui

[PATCH] ob-python: Fix async evaluation

2023-07-10 Thread Liu Hui
"(require 'ob-python)" 3. Open test.org, then start a python shell with M-x run-python, which should create a buffer named "*Python 3*" 4. Press C-c C-c on the src block. Then an error "No inferior Python process running" is shown. From 75ca16a21fe409aeb37b9bf0d9789

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-06 Thread Liu Hui
Jack Kamm 于2023年7月6日周四 11:49写道: > I would propose the following instead: for ":results output graphics", > ob-python should plot the gcf, and clear it beforehand. But for > ":results value graphics", the ob-python block should return a > matplotlib Figure object to plot, which would allow

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Liu Hui
Jack Kamm 于2023年7月5日周三 13:13写道: > 1. Do you need to add a call to pyplot.gcf().clear(), in case of > multiple blocks in a session? I don't think so. Some users may want to keep the figure between blocks, and they can always clear the figure themselves when necessary. > 2. Would it make sense

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Liu Hui
5,4,3,2,1]) > plt.show() > #+end_src OK, I think that it is better to turn off the feature by default and I have updated the patch. Inspired by ob-R, some extra header arguments are supported. Thanks. From 5f3fc8602c0eb1f6d0c072bd0c1a6bb883b8c9f9 Mon Sep 17 00:00:00 2001 From: Liu Hui Date: W

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
Ihor Radchenko 于2023年7月3日周一 19:41写道: > This already works, even without the patch. Yes. It means the patch doesn't break current usage. > > In this case, `graphics' can be removed too. > > May you elaborate? > > #+begin_src python :results file > implies that the result of execution is file

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
f they want to use `graphics' in the header argument. If necessary, ob-python may support such libraries too. From 8ea69d66552ee0217b7f5c8089b91424b92c3b5a Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Mon, 3 Jul 2023 11:13:58 +0800 Subject: [PATCH] ob-python: support header argument `:results file graph

[PATCH] ob-python: support header argument `:results file graphics'

2023-07-02 Thread Liu Hui
00:00:00 2001 From: Liu Hui Date: Mon, 3 Jul 2023 11:13:58 +0800 Subject: [PATCH] ob-python: support header argument `:results file graphics' * lisp/ob-python.el (org-babel-execute:python): Save current figure to file when the result type is `file graphics'. (org-babel-python-save-graphics):

[PATCH] org-agenda-filter-by-category: fix 'no category' error

2023-02-02 Thread Liu Hui
b12708b54ec8ef26265c64af630e Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Wed, 1 Feb 2023 13:35:49 +0800 Subject: [PATCH] org-agenda: Fix `org-agenda-filter-by-category' * lisp/org-agenda.el (org-agenda-filter-by-category): Use `org-agenda-get-category' to get the category at current line. ---

Re: org-agenda-tag-filter-preset: maybe a recent bug?

2022-10-17 Thread Liu Hui
Hi Garjola, The preset of filter is not supposed to be used with individual command. The docstring of 'org-agenda-tag-filter-preset' says: > The preset filter is a global property of the entire agenda view. In > a block agenda, it will not work reliably to define a filter for one > of the

Re: [PATCH] Re: [BUG] org-agenda-remove-restriction-lock does not remove file lock [9.5.2 (release_9.5.2-17-gea6b74 @ /nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0/share/emacs/29.0.

2022-10-12 Thread Liu Hui
for related variables except `org-agenda-last-dispatch-buffer', which is actually not used by any other org-mode code. Please see the patch below. >From 907499f16769e5a5353170c13f09595584530139 Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Wed, 12 Oct 2022 14:02:05 +0800 Subject: [PATCH] org-ag

Re: [PATCH] Re: [BUG] org-agenda-remove-restriction-lock does not remove file lock [9.5.2 (release_9.5.2-17-gea6b74 @ /nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0/share/emacs/29.0.

2022-10-09 Thread Liu Hui
ly tested in several places and I don't find any problem with the change. Therefore I suggest the attached patch, where the value of `org-agenda-restrict' is changed from nil to t during temporary and extended file restriction. >From f4e46051fbb13adadbbafeebab343383e1bca35a Mon Sep 17 00:00:00 20

Re: [PATCH] lisp/org-agenda.el: Fix filter preset problem for sticky agenda

2022-10-08 Thread Liu Hui
Ihor Radchenko writes: > Applied onto main with minor amendments (mostly added double space " " > between sentences in docstrings and the commit message). > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=edf5afc1d833a814cf97e814194b83b82f26a294 Thanks! > Also, while we are

Re: [PATCH] lisp/org-agenda.el: Fix filter preset problem for sticky agenda

2022-10-05 Thread Liu Hui
w the udpated patch can address the case containing one command by changing another global symbol property to per-buffer text property. >From 718cb5258a407d8a51eb4a5bac3d0c8025a3f198 Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Tue, 4 Oct 2022 11:12:41 +0800 Subject: [PATCH] Fix filter p

[PATCH] lisp/org-agenda.el: Fix filter preset problem for sticky agenda

2022-10-03 Thread Liu Hui
u > can (probably) see from the mode line, the filter is set to "+bar", and > refreshing the buffer causes all the TODOs to be lost because it now has > the wrong filter. Because the filter presets are stored as symbol properties, they cannot be used with multiple sticky agen

[BUG] Inline images cannot be displayed [9.5 (release_9.5-108-g93132c @ /tmp/org-mode/lisp/)]

2021-10-15 Thread Liu Hui
Hi, Org mode cannot display inline images because of an error caused by org-display-inline-image--width. It seems display-line-numbers-width is regarded as a number unconditionally. Recipe: 1. emacs -Q 2. Make the following settings: (setq org-image-actual-width nil) (setq

[O] Problem of refile in the org capture buffer

2017-02-17 Thread Liu Hui
Hello, I find C-c C-w (refile) in the org capture buffer doesn't work correctly when there are empty lines (containing the point) in the end of buffer. Steps to reproduce: 1. echo -e "* A\n* B" > /tmp/test.org; cat /tmp/test.org * A * B 2. Emacs -Q, and evaluate the code: (setq

[O] Problem of refile in the org capture buffer

2017-02-17 Thread Liu Hui
Hello, I find C-c C-w (refine) in the org capture buffer doesn't work correctly when there are empty lines (containing the point) in the end of buffer. Steps to reproduce: 1. echo -e "* A\n* B" > /tmp/test.org; cat /tmp/test.org * A * B 2. Emacs -Q, and evaluate the code: (setq