* [PATCH] improving ses-jump for accepting cell names as lowercase @ 2022-03-08 4:39 andres.ramirez 2022-03-09 14:09 ` Lars Ingebrigtsen 0 siblings, 1 reply; 6+ messages in thread From: andres.ramirez @ 2022-03-08 4:39 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 62 bytes --] Hi. This patch improves ses-jump a little bit. Best Regards [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: ses --] [-- Type: text/x-patch, Size: 708 bytes --] diff -u /home/user/downloads/opt_clone/emacs/lisp/ses.el /home/user/downloads/opt_clone/emacs/lisp/ses.el.bak --- /home/user/downloads/opt_clone/emacs/lisp/ses.el 2022-02-19 16:12:38.757109243 +0000 +++ /home/user/downloads/opt_clone/emacs/lisp/ses.el.bak 2022-03-08 04:28:00.653553511 +0000 @@ -2245,8 +2245,8 @@ ses--named-cell-hashmap) names))))) (if (string= s "") - (user-error "Invalid cell name") - (list (intern s))))) + (user-error "Empty cell name") + (list (intern (upcase s)))))) (let ((rowcol (ses-sym-rowcol sym))) (or rowcol (error "Invalid cell name")) (if (eq (symbol-value sym) '*skip*) Diff finished. Tue Mar 8 04:28:36 2022 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improving ses-jump for accepting cell names as lowercase 2022-03-08 4:39 [PATCH] improving ses-jump for accepting cell names as lowercase andres.ramirez @ 2022-03-09 14:09 ` Lars Ingebrigtsen 2022-03-09 15:20 ` andrés ramírez 0 siblings, 1 reply; 6+ messages in thread From: Lars Ingebrigtsen @ 2022-03-09 14:09 UTC (permalink / raw) To: andres.ramirez; +Cc: emacs-devel andres.ramirez <rrandresf@gmail.com> writes: > This patch improves ses-jump a little bit. [...] > - (user-error "Invalid cell name") > - (list (intern s))))) > + (user-error "Empty cell name") > + (list (intern (upcase s)))))) I've never used ses before -- do cells have only upper-case names? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improving ses-jump for accepting cell names as lowercase 2022-03-09 14:09 ` Lars Ingebrigtsen @ 2022-03-09 15:20 ` andrés ramírez [not found] ` <CAPAOBV8G1xtD7dxEOexM8kozfnUPEPnhxDO5nFTB9Q71vBNbhA@mail.gmail.com> 0 siblings, 1 reply; 6+ messages in thread From: andrés ramírez @ 2022-03-09 15:20 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: jyavner, vincentb1, Boruch Baum, emacs-devel Hi. Lars. My comments below. >>>>> "Lars" == Lars Ingebrigtsen <larsi@gnus.org> writes: Lars> andres.ramirez <rrandresf@gmail.com> writes: >> This patch improves ses-jump a little bit. Lars> [...] >> - (user-error "Invalid cell name") - (list (intern s))))) + (user-error "Empty cell name") + >> (list (intern (upcase s)))))) Lars> I've never used ses before -- do cells have only upper-case names? This is my gut feeling. I started using ses a couple of year ago. It is really handy having a networked spreadsheet software :). Org-mode tables are handy for simple things But for a little bit complex calculations ses-mode is paramount. This code comes from 2002. I think It should be around emacs19 or emacs20. At that time it was just the TUI for emacs. Probably at that time ses-jump was not so useful as it could be today. I could be wrong. But nowadays We have 'display-line-numbers'. So When activating display-line-numbers it is simpler to use ses-jump as we have a line-number indicator at the left of the frame. Back to your question. In the past lotus-1-2-3 used to have just upper-case names on rows. So probably the answer is Yes. JIC I am going to Cc the author and the maintainer. Perhaps They could tell us about it. I have skimmed the code and have not found the answer. Also I am sharing a couple of images for giving You a better idea: ,---- [ cli ] | http://0x0.st/oPDb.png `---- ,---- [ lucid ] | http://0x0.st/oPDc.png `---- Best Regards ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAPAOBV8G1xtD7dxEOexM8kozfnUPEPnhxDO5nFTB9Q71vBNbhA@mail.gmail.com>]
* RE: [PATCH] improving ses-jump for accepting cell names as lowercase [not found] ` <CAPAOBV8G1xtD7dxEOexM8kozfnUPEPnhxDO5nFTB9Q71vBNbhA@mail.gmail.com> @ 2022-03-10 12:30 ` Vincent Belaïche 2022-03-11 13:32 ` andrés ramírez 0 siblings, 1 reply; 6+ messages in thread From: Vincent Belaïche @ 2022-03-10 12:30 UTC (permalink / raw) To: rrandresf@gmail.com, Lars Ingebrigtsen; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 2393 bytes --] Hello, Please note that cells can be renamed and you have auto-completion on renamed cells. Concerning the letters case, maybe it would be even more flexible if the user had some sort of hook function to pre-process cell names that are not in the renamed cell list, then you could set this function to upcase, but some other setting could allow to enter some coordinate. Rahter than applying your patch, I can update the code in this way. V. ________________________________ De : Vincent Belaïche <vincent.belaiche@gmail.com> Envoyé : jeudi 10 mars 2022 13:26 À : Vincent Belaïche <vincent.b.1@hotmail.fr> Objet : Re: [PATCH] improving ses-jump for accepting cell names as lowercase Le mer. 9 mars 2022 à 16:20, andrés ramírez <rrandresf@gmail.com> a écrit : > > Hi. Lars. My comments below. > > >>>>> "Lars" == Lars Ingebrigtsen <larsi@gnus.org> writes: > > Lars> andres.ramirez <rrandresf@gmail.com> writes: > >> This patch improves ses-jump a little bit. > > Lars> [...] > > >> - (user-error "Invalid cell name") - (list (intern s))))) + (user-error "Empty cell name") + > >> (list (intern (upcase s)))))) > > Lars> I've never used ses before -- do cells have only upper-case names? > > This is my gut feeling. I started using ses a couple of year ago. It > is really handy having a networked spreadsheet software :). Org-mode > tables are handy for simple things But for a little bit complex > calculations ses-mode is paramount. > > This code comes from 2002. I think It should be around emacs19 or > emacs20. At that time it was just the TUI for emacs. Probably at that > time ses-jump was not so useful as it could be today. I could be > wrong. But nowadays We have 'display-line-numbers'. So When activating > display-line-numbers it is simpler to use ses-jump as we have a > line-number indicator at the left of the frame. > > Back to your question. In the past lotus-1-2-3 used to have just > upper-case names on rows. So probably the answer is Yes. > > JIC I am going to Cc the author and the maintainer. Perhaps They could > tell us about it. I have skimmed the code and have not found the answer. > > Also I am sharing a couple of images for giving You a better idea: > ,---- [ cli ] > | http://0x0.st/oPDb.png > `---- > > ,---- [ lucid ] > | http://0x0.st/oPDc.png > `---- > > Best Regards [-- Attachment #2: Type: text/html, Size: 3789 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improving ses-jump for accepting cell names as lowercase 2022-03-10 12:30 ` Vincent Belaïche @ 2022-03-11 13:32 ` andrés ramírez 2022-03-18 18:42 ` Vincent Belaïche 0 siblings, 1 reply; 6+ messages in thread From: andrés ramírez @ 2022-03-11 13:32 UTC (permalink / raw) To: Vincent Belaïche; +Cc: Lars Ingebrigtsen, emacs-devel Hi. Vincent. My comments below. >>>>> "Vincent" == Vincent Belaïche <vincent.b.1@hotmail.fr> writes: Vincent> Hello, Vincent> Please note that cells can be renamed and you have auto-completion on renamed cells. OK. Vincent> Concerning the letters case, maybe it would be even more flexible if the user had some Vincent> sort of hook function to pre-process cell names that are not in the renamed cell list, Vincent> then you could set this function to upcase, but some other setting could allow to enter Vincent> some coordinate. Vincent> Rahter than applying your patch, I can update the code in this way. V. It sounds good. Best Regards ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] improving ses-jump for accepting cell names as lowercase 2022-03-11 13:32 ` andrés ramírez @ 2022-03-18 18:42 ` Vincent Belaïche 0 siblings, 0 replies; 6+ messages in thread From: Vincent Belaïche @ 2022-03-18 18:42 UTC (permalink / raw) To: andrés ramírez; +Cc: Lars Ingebrigtsen, emacs-devel [-- Attachment #1.1: Type: text/plain, Size: 1258 bytes --] Hello Andrés, Here is what I have done. I have not yet pushed the changes to master. Comments welcome. I need to update the manual, and maybe to add some unitary tests. I will do it when time allows … sorry for the delay … V. ________________________________ De : andrés ramírez <rrandresf@gmail.com> Envoyé : vendredi 11 mars 2022 14:32 À : Vincent Belaïche <vincent.b.1@hotmail.fr> Cc : Lars Ingebrigtsen <larsi@gnus.org>; emacs-devel <emacs-devel@gnu.org> Objet : Re: [PATCH] improving ses-jump for accepting cell names as lowercase Hi. Vincent. My comments below. >>>>> "Vincent" == Vincent Belaïche <vincent.b.1@hotmail.fr> writes: Vincent> Hello, Vincent> Please note that cells can be renamed and you have auto-completion on renamed cells. OK. Vincent> Concerning the letters case, maybe it would be even more flexible if the user had some Vincent> sort of hook function to pre-process cell names that are not in the renamed cell list, Vincent> then you could set this function to upcase, but some other setting could allow to enter Vincent> some coordinate. Vincent> Rahter than applying your patch, I can update the code in this way. V. It sounds good. Best Regards [-- Attachment #1.2: Type: text/html, Size: 3350 bytes --] [-- Attachment #2: ses.el.gz --] [-- Type: application/x-gzip, Size: 43620 bytes --] [-- Attachment #3: ses.el.diff --] [-- Type: application/octet-stream, Size: 3153 bytes --] diff --git a/lisp/ses.el b/lisp/ses.el index 45e323e805..66523ae0ca 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -112,6 +112,24 @@ ses-mode-hook :group 'ses :type 'hook) +(defcustom ses-jump-cell-name-function 'upcase + "Function to process the string passed to function ‘ses-jump’. Set it to 'identity to make no change. +Set it to 'upcase to make cell name change case isensitive. + + May return + +* a string, in this case this must be a cell name. +* a (row . col) cons cell, in this case that must be valid cell coordinate." + :group 'ses + :type 'function) + +(defcustom ses-jump-prefix-function 'ses-jump-prefix + "Function that takes the prefix argument passed to function ‘ses-jump’. It may return the same +sort of thing as ‘ses-jump-cell-name-function’." + :group 'ses + :type 'function) + + ;;---------------------------------------------------------------------------- ;; Global variables and constants @@ -2233,25 +2251,40 @@ ses-create-header-string ;;---------------------------------------------------------------------------- ;; Redisplay and recalculation ;;---------------------------------------------------------------------------- +(defun ses-jump-prefix (prefix-int) + "Convert an integer into a (ROW . COL), by numbering cells starting from 0 from top left to bottom right, going row by row." + (and (>= prefix-int 0) + (< prefix-int (* ses--numcols ses--numrows)) + (cons (/ prefix-int ses--numcols) (% prefix-int ses--numcols)))) -(defun ses-jump (sym) + +(defun ses-jump (&optional arg) "Move point to cell SYM." - (interactive (let* (names - (s (completing-read - "Jump to cell: " - (and ses--named-cell-hashmap - (progn (maphash (lambda (key _val) - (push (symbol-name key) names)) - ses--named-cell-hashmap) - names))))) - (if (string= s "") - (user-error "Invalid cell name") - (list (intern s))))) - (let ((rowcol (ses-sym-rowcol sym))) + (interactive "P") + (let* (names + (sym + (if arg (funcall ses-jump-prefix-function (prefix-numeric-value arg)) + (completing-read + "Jump to cell: " + (and ses--named-cell-hashmap + (progn (maphash (lambda (key _val) + (push (symbol-name key) names)) + ses--named-cell-hashmap) + names)))))) + (and (stringp sym) + (not (gethash (intern sym) ses--named-cell-hashmap)) + (setq sym (funcall ses-jump-cell-name-function sym))) + (if (stringp sym) + (if (string= sym "") + (user-error "Invalid cell name") + (setq sym (intern sym)))) + (let ((rowcol (if (consp sym) + (prog1 sym (setq sym (ses-cell-symbol (car sym) (cdr sym)))) + (ses-sym-rowcol sym)))) (or rowcol (error "Invalid cell name")) (if (eq (symbol-value sym) '*skip*) (error "Cell is covered by preceding cell")) - (ses-goto-print (car rowcol) (cdr rowcol)))) + (ses-goto-print (car rowcol) (cdr rowcol))))) (defun ses-jump-safe (cell) "Like `ses-jump', but no error if invalid cell." ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-18 18:42 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-08 4:39 [PATCH] improving ses-jump for accepting cell names as lowercase andres.ramirez 2022-03-09 14:09 ` Lars Ingebrigtsen 2022-03-09 15:20 ` andrés ramírez [not found] ` <CAPAOBV8G1xtD7dxEOexM8kozfnUPEPnhxDO5nFTB9Q71vBNbhA@mail.gmail.com> 2022-03-10 12:30 ` Vincent Belaïche 2022-03-11 13:32 ` andrés ramírez 2022-03-18 18:42 ` Vincent Belaïche
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).