From: Kyle Meyer <kyle@kyleam.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Free up C-c SPC/org-table-blank-field?
Date: Thu, 04 Feb 2021 23:45:14 -0500 [thread overview]
Message-ID: <87lfc3f7hh.fsf@kyleam.com> (raw)
In-Reply-To: <871rdv6upl.fsf@ericabrahamsen.net>
Eric Abrahamsen writes:
> Kyle Meyer <kyle@kyleam.com> writes:
>
[...]
>> Does it actually need a key binding? I've never used it and just use
>> <tab> to move to the next field, leaving the field blank.
>
> I assume it's meant for blanking a field you've already typed something
> into. But yes, I can't imagine it's a heavily-used command, and I
> suspect the C-c <SPC> binding is mostly mnemonic: "make this field
> contain only blanks".
[ Just for clarity: from this point on, the outer text you were quoting
was from Tim Cross, not me. ]
> I thought Emacs might have some easy way to let a key event "fall
> through" to other keymaps, but I haven't been able to find anything
> immediately obvious. Maybe I can ask on emacs.devel...
Yeah, I don't know either. When I read your initial message, I assumed
you were thinking of some sort of key lookup. Something like below
seems to works, but it feels hacky and is probably pretty brittle.
diff --git a/lisp/org-table.el b/lisp/org-table.el
index ef4672e1b..c6d0e91c4 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1203,22 +1203,28 @@ (defun org-table-goto-line (N)
(= cnt N)))
;;;###autoload
-(defun org-table-blank-field ()
+(defun org-table-blank-field (&optional interactive-p)
"Blank the current table field or active region."
- (interactive)
- (org-table-check-inside-data-field)
- (if (and (called-interactively-p 'any) (org-region-active-p))
- (let (org-table-clip)
- (org-table-cut-region (region-beginning) (region-end)))
- (skip-chars-backward "^|")
- (backward-char 1)
- (if (looking-at "|[^|\n]+")
- (let* ((pos (match-beginning 0))
- (match (match-string 0))
- (len (org-string-width match)))
- (replace-match (concat "|" (make-string (1- len) ?\ )))
- (goto-char (+ 2 pos))
- (substring match 1)))))
+ (interactive "p")
+ (cond
+ ((org-at-table-p)
+ (org-table-check-inside-data-field)
+ (if (and interactive-p (org-region-active-p))
+ (let (org-table-clip)
+ (org-table-cut-region (region-beginning) (region-end)))
+ (skip-chars-backward "^|")
+ (backward-char 1)
+ (if (looking-at "|[^|\n]+")
+ (let* ((pos (match-beginning 0))
+ (match (match-string 0))
+ (len (org-string-width match)))
+ (replace-match (concat "|" (make-string (1- len) ?\ )))
+ (goto-char (+ 2 pos))
+ (substring match 1)))))
+ (interactive-p
+ (let ((key (lookup-key (current-global-map) (this-command-keys))))
+ (unless (numberp key)
+ (call-interactively key))))))
(defun org-table-get-field (&optional n replace)
"Return the value of the field in column N of current row.
next prev parent reply other threads:[~2021-02-05 4:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 18:05 Free up C-c SPC/org-table-blank-field? Eric Abrahamsen
2021-02-03 6:16 ` Kyle Meyer
2021-02-03 6:26 ` Tim Cross
2021-02-05 3:48 ` Eric Abrahamsen
2021-02-05 4:45 ` Kyle Meyer [this message]
2021-02-05 5:32 ` Tim Cross
2021-02-05 9:41 ` Christian Moe
2021-02-05 10:44 ` Carsten Dominik
2021-02-05 18:33 ` Eric Abrahamsen
2021-02-11 9:45 ` Carsten Dominik
2021-03-04 19:49 ` Eric Abrahamsen
2021-04-28 3:50 ` Bastien
2021-05-01 21:09 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfc3f7hh.fsf@kyleam.com \
--to=kyle@kyleam.com \
--cc=emacs-orgmode@gnu.org \
--cc=eric@ericabrahamsen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).