emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Using backticks for the inline code delimeter?
Date: Wed, 21 Apr 2021 08:30:08 +1000	[thread overview]
Message-ID: <87y2dcim9p.fsf@gmail.com> (raw)
In-Reply-To: <CAN_Dec-bKBnV=tDYgOsphqhWeg3ZnuLXCUO0WO48s41HxRKR7g@mail.gmail.com>


Matt Price <moptop99@gmail.com> writes:

> On Wed., Mar. 31, 2021, 3:22 p.m. Timothy, <tecosaur@gmail.com> wrote:
>
>  autofrettage <autofrettage@protonmail.ch> writes:
>
>  > Quick and Dirty: Bind key '`' to ~ in Emacs?
>  >
>  > (I guess it is clear I haven't thought about the consequences.)
>
>  You can add that just to the Org-mode map. That wouldn't be too bad,
>  there's always C-q.
>
> Is it possible to bind a key in org-mode but bind it back to another character if you're in a special environment, eg a code block? That would
> probably be my preference. So "`" inserts "~" when you're writing text but "`" in an elisp or markdown SRC block, for instance. 
>
> I guess just write a function that checks context? Presumably all the overloaded keybindings do this already but I guess I don't really know how they
> do so. 
>

Yes, you can do that. However, results can vary. The 'bottleneck' is in
determining context. If that is easy, typically no problems. However, if
you need something complex or need to scan a large part of the buffer to
determine the context, then it can be problematic. 

> I do in general wish it were easier to switch between writing markdown and writing org, since I often have to write markdown for work. 
>

Sounds like what you really need to do is define a set of key bindings
which use the same bindings in both org and markup modes (different
bound functions obviously). Instead of entering the character for 'code'
using org syntax when in org and markdown syntax when in markdown,
you just train your fingers to hit the key binding you have defined for
entering 'code'. One nice advantage of this approach is that you can
define functions such that if you hit that key binding it will insert
the mode specific character if no region is selected, but if a region is
selected, wrap that region using the nominated character. This is handy when
editing a document because if you come across a section and want to have
it rendered has code, bold, underlined etc, you can just select the
target region and hit the appropriate key and job done.

The other nice thing about this approach is you can generalise this
further to other modes, even HTML. You then think in terms of either
formatting or semantics (depending on how you define the bindings) and
not the lower level syntax. 

The challenge can be in identifying the most appropriate key bindings.
This can depend on the platform you use as well. When I was only using
Linux, I used the 'super' key for this and it was great. However, when I
also started using a mac, I had to define a new scheme. It can take a
bit of work to setup initially, but I think it is worth the effort. I
now have the same bindings in multiple modes, so regardless of whether
I'm writing markdown, org, html, rich text, etc, I just hit the same key
bindings to mark content as code, bold, italic, etc. 

-- 
Tim Cross


  parent reply	other threads:[~2021-04-20 23:12 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 18:48 George Mauer
2021-03-31 19:16 ` autofrettage
2021-03-31 19:19   ` Timothy
2021-04-01  6:03     ` Marcin Borkowski
2021-04-20 13:30     ` Matt Price
2021-04-20 20:24       ` John Kitchin
2021-04-21 22:37         ` Matt Price
2021-04-20 22:30       ` Tim Cross [this message]
2021-04-21 19:22         ` John Kitchin
2021-04-21 19:49           ` Tim Cross
2021-03-31 19:24 ` Sébastien Miquel
2021-04-01 16:49   ` Maxim Nikulin
2021-04-01 17:05     ` Timothy
2021-04-01 18:43       ` Samuel Wales
2021-04-01 23:14         ` Tim Cross
2021-04-01 23:30           ` Joost Kremers
2021-04-02  0:28             ` Tim Cross
2021-04-04  1:13               ` Tom Gillespie
2021-04-04 10:03                 ` Joost Kremers
2021-04-04 12:19                   ` Nicolas Goaziou
2021-04-04 16:46                     ` Bill Burdick
2021-04-04 17:24                       ` Nicolas Goaziou
2021-04-04 19:33                     ` Joost Kremers
2021-04-04 23:06                       ` Nicolas Goaziou
2021-04-06 15:03                         ` Maxim Nikulin
2021-04-19  9:27                           ` Nicolas Goaziou
2021-03-31 19:28 ` Timothy
2021-03-31 19:55   ` autofrettage
2021-03-31 20:31 ` Diego Zamboni
2021-03-31 21:51   ` George Mauer
2021-03-31 22:27     ` Dr. Arne Babenhauserheide
2021-03-31 22:38       ` Tim Cross
2021-04-01  0:25         ` Samuel Wales
2021-04-01  1:11 ` Bill Burdick
2021-04-01  3:42 ` Greg Minshall
2021-04-01  9:32   ` autofrettage
2021-04-02 11:23     ` Andreas Eder
2021-04-04 17:06       ` Maxim Nikulin
2022-03-19  3:17 chris
2022-03-19  3:24 ` chris

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=87y2dcim9p.fsf@gmail.com \
    --to=theophilusx@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Using backticks for the inline code delimeter?' \
    /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

Code repositories for project(s) associated with this 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).