Skip to content

Commit

Permalink
Use C-c C-l for inserting links, move jumping to C-c C-d
Browse files Browse the repository at this point in the history
This is related to GH-199.
  • Loading branch information
jrblevin committed Jun 18, 2017
1 parent 5b40399 commit 4835f37
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 60 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

* **Breaking changes:**

- Link insertion and editing has been consolidated into one
command, `markdown-insert-link`, bound to <kbd>C-c C-k</kbd>.
As such, the previous separate link insertion keybindings have
been removed: <kbd>C-c C-a l</kbd>, <kbd>C-c C-a L</kbd>,
<kbd>C-c C-a r</kbd>, and <kbd>C-c C-a u</kbd>.
- Jumping between references and reference definitions via
`markdown-jump`, previously bound to <kbd>C-c C-k</kbd>, has
been moved to <kbd>C-c C-d</kbd>.
- Rename internal `markdown-link-link` to `markdown-link-url`
for clarity.
- The old inline image toggling command <kbd>C-c C-i C-t</kbd>
Expand Down
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ GNU Emacs since 24.3. Users of GNU Emacs 24.1 and 24.2 can install
## Usage

Keybindings are grouped by prefixes based on their function. For
example, the commands for inserting links are grouped under `C-c
C-a`, where the <kbd>C-a</kbd> is a mnemonic for the HTML `<a>` tag. In
other cases, the connection to HTML is not direct. For example,
commands dealing with headings begin with <kbd>C-c C-t</kbd> (mnemonic:
example, the commands for styling text are grouped under <kbd>C-c C-s</kbd>
and commands dealing with headings begin with <kbd>C-c C-t</kbd> (mnemonic:
titling). The primary commands in each group will are described
below. You can obtain a list of all keybindings by pressing `C-c
C-h`. Movement and shifting commands tend to be associated with
Expand All @@ -174,13 +172,14 @@ are grouped under the <kbd>C-c C-c</kbd> prefix. The most commonly used
commands are described below. You can obtain a list of all
keybindings by pressing <kbd>C-c C-h</kbd>.

* Hyperlinks: <kbd>C-c C-a</kbd>
* Hyperlinks: <kbd>C-c C-l</kbd>

In this group, <kbd>C-c C-a l</kbd> inserts links, either inline,
reference, or plain URLs. The URL or `[reference]` label, link
text, and optional title are entered through a series of
interactive prompts. The type of link is determined by which
values are provided:
<kbd>C-c C-l</kbd> (`markdown-insert-link`) is a general command for
inserting standard Markdown links of any form: either inline
links, reference links, or plain URLs in angle brackets. The
URL or `[reference]` label, link text, and optional title are
entered through a series of interactive prompts. The type of
link is determined by which values are provided:

* If both a URL and link text are given, insert an inline link:
`[text](url)`.
Expand All @@ -191,9 +190,10 @@ keybindings by pressing <kbd>C-c C-h</kbd>.
* If only a URL is given, insert a plain URL link:
`<url>`.

If there is an active region, use the text as the default URL,
if it seems to be a URL, or link text value otherwise. The region
will be deleted and replaced by the link.
If there is an active region, this command uses the region as
either the default URL (if it seems to be a URL) or link text
value otherwise. The region will be deleted and replaced by the
link.

Note that this function can be used to convert a link from one
type to another (inline, reference, or plain URL) by
Expand All @@ -207,19 +207,6 @@ keybindings by pressing <kbd>C-c C-h</kbd>.
added to the end of the reference definition and will be used
to populate the title attribute when converted to HTML.

<kbd>C-c C-a f</kbd> inserts a footnote marker at the point, inserts a
footnote definition below, and positions the point for
inserting the footnote text. Note that footnotes are an
extension to Markdown and are not supported by all processors.

<kbd>C-c C-a w</kbd> behaves much like the link insertion command
and inserts a wiki link of the form `[[WikiLink]]`. If there
is an active region, use the region as the link text. If the
point is at a word, use the word as the link text. If there is
no active region and the point is not at word, simply insert
link markup. Note that wiki links are an extension to Markdown
and are not supported by all processors.

* Images: <kbd>C-c C-i</kbd>

<kbd>C-c C-i i</kbd> inserts markup for an inline image, using the
Expand Down Expand Up @@ -291,6 +278,22 @@ keybindings by pressing <kbd>C-c C-h</kbd>.
With a numeric prefix <kbd>N</kbd>, insert the string in position <kbd>N</kbd>
(counting from 1).

* Footnotes: <kbd>C-c C-a f</kbd>

<kbd>C-c C-a f</kbd> inserts a footnote marker at the point, inserts a
footnote definition below, and positions the point for
inserting the footnote text. Note that footnotes are an
extension to Markdown and are not supported by all processors.

* Wiki Links: <kbd>C-c C-a f</kbd>

<kbd>C-c C-a w</kbd> inserts a wiki link of the form `[[WikiLink]]`. If
there is an active region, use the region as the link text. If the
point is at a word, use the word as the link text. If there is
no active region and the point is not at word, simply insert
link markup. Note that wiki links are an extension to Markdown
and are not supported by all processors.

* Markdown and Maintenance Commands: <kbd>C-c C-c</kbd>

*Compile:* <kbd>C-c C-c m</kbd> will run Markdown on the current buffer
Expand Down Expand Up @@ -344,9 +347,9 @@ keybindings by pressing <kbd>C-c C-h</kbd>.
or in the other window with the <kbd>C-u</kbd> prefix). Use <kbd>M-p</kbd> and
<kbd>M-n</kbd> to quickly jump to the previous or next link of any type.

* Jumping: <kbd>C-c C-l</kbd>
* Jumping: <kbd>C-c C-d</kbd>

Use <kbd>C-c C-l</kbd> to jump from the object at point to its counterpart
Use <kbd>C-c C-d</kbd> to jump from the object at point to its counterpart
elsewhere in the text, when possible. Jumps between reference
links and definitions; between footnote markers and footnote
text. If more than one link uses the same reference name, a
Expand Down
65 changes: 33 additions & 32 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@
;;; Usage:

;; Keybindings are grouped by prefixes based on their function. For
;; example, the commands for inserting links are grouped under `C-c
;; C-a`, where the `C-a` is a mnemonic for the HTML `<a>` tag. In
;; other cases, the connection to HTML is not direct. For example,
;; commands dealing with headings begin with `C-c C-t` (mnemonic:
;; example, the commands for styling text are grouped under `C-c C-s`
;; and commands dealing with headings begin with `C-c C-t` (mnemonic:
;; titling). The primary commands in each group will are described
;; below. You can obtain a list of all keybindings by pressing `C-c
;; C-h`. Movement and shifting commands tend to be associated with
Expand All @@ -190,13 +188,14 @@
;; commands are described below. You can obtain a list of all
;; keybindings by pressing `C-c C-h`.
;;
;; * Hyperlinks: `C-c C-a`
;; * Hyperlinks: `C-c C-l`
;;
;; In this group, `C-c C-a l` inserts links, either inline,
;; reference, or plain URLs. The URL or `[reference]` label, link
;; text, and optional title are entered through a series of
;; interactive prompts. The type of link is determined by which
;; values are provided:
;; `C-c C-l` (`markdown-insert-link`) is a general command for
;; inserting standard Markdown links of any form: either inline
;; links, reference links, or plain URLs in angle brackets. The
;; URL or `[reference]` label, link text, and optional title are
;; entered through a series of interactive prompts. The type of
;; link is determined by which values are provided:
;;
;; * If both a URL and link text are given, insert an inline link:
;; `[text](url)`.
Expand All @@ -207,9 +206,10 @@
;; * If only a URL is given, insert a plain URL link:
;; `<url>`.
;;
;; If there is an active region, use the text as the default URL,
;; if it seems to be a URL, or link text value otherwise. The region
;; will be deleted and replaced by the link.
;; If there is an active region, this command uses the region as
;; either the default URL (if it seems to be a URL) or link text
;; value otherwise. The region will be deleted and replaced by the
;; link.
;;
;; Note that this function can be used to convert a link from one
;; type to another (inline, reference, or plain URL) by
Expand All @@ -223,19 +223,6 @@
;; added to the end of the reference definition and will be used
;; to populate the title attribute when converted to HTML.
;;
;; `C-c C-a f` inserts a footnote marker at the point, inserts a
;; footnote definition below, and positions the point for
;; inserting the footnote text. Note that footnotes are an
;; extension to Markdown and are not supported by all processors.
;;
;; `C-c C-a w` behaves much like the link insertion command
;; and inserts a wiki link of the form `[[WikiLink]]`. If there
;; is an active region, use the region as the link text. If the
;; point is at a word, use the word as the link text. If there is
;; no active region and the point is not at word, simply insert
;; link markup. Note that wiki links are an extension to Markdown
;; and are not supported by all processors.
;;
;; * Images: `C-c C-i`
;;
;; `C-c C-i i` inserts markup for an inline image, using the
Expand Down Expand Up @@ -307,6 +294,22 @@
;; With a numeric prefix `N`, insert the string in position `N`
;; (counting from 1).
;;
;; * Footnotes: `C-c C-a f`
;;
;; `C-c C-a f` inserts a footnote marker at the point, inserts a
;; footnote definition below, and positions the point for
;; inserting the footnote text. Note that footnotes are an
;; extension to Markdown and are not supported by all processors.
;;
;; * Wiki Links: `C-c C-a f`
;;
;; `C-c C-a w` inserts a wiki link of the form `[[WikiLink]]`. If
;; there is an active region, use the region as the link text. If the
;; point is at a word, use the word as the link text. If there is
;; no active region and the point is not at word, simply insert
;; link markup. Note that wiki links are an extension to Markdown
;; and are not supported by all processors.
;;
;; * Markdown and Maintenance Commands: `C-c C-c`
;;
;; *Compile:* `C-c C-c m` will run Markdown on the current buffer
Expand Down Expand Up @@ -360,9 +363,9 @@
;; or in the other window with the `C-u` prefix). Use `M-p` and
;; `M-n` to quickly jump to the previous or next link of any type.
;;
;; * Jumping: `C-c C-l`
;; * Jumping: `C-c C-d`
;;
;; Use `C-c C-l` to jump from the object at point to its counterpart
;; Use `C-c C-d` to jump from the object at point to its counterpart
;; elsewhere in the text, when possible. Jumps between reference
;; links and definitions; between footnote markers and footnote
;; text. If more than one link uses the same reference name, a
Expand Down Expand Up @@ -5463,6 +5466,7 @@ Assumes match data is available for `markdown-regex-italic'."
(defvar markdown-mode-map
(let ((map (make-keymap)))
;; Element insertion
(define-key map (kbd "C-c C-l") 'markdown-insert-link)
(define-key map "\C-c\C-al" 'markdown-insert-link)
(define-key map "\C-c\C-af" 'markdown-insert-footnote)
(define-key map "\C-c\C-aw" 'markdown-insert-wiki-link)
Expand All @@ -5489,11 +5493,8 @@ Assumes match data is available for `markdown-regex-italic'."
(define-key map "\C-c\C-sP" 'markdown-insert-gfm-code-block)
(define-key map "\C-c-" 'markdown-insert-hr)
;; Element insertion (deprecated)
(define-key map "\C-c\C-ar" 'markdown-insert-reference-link-dwim)
(define-key map "\C-c\C-tt" 'markdown-insert-header-setext-1)
(define-key map "\C-c\C-ts" 'markdown-insert-header-setext-2)
(define-key map "\C-c\C-aL" 'markdown-insert-link)
(define-key map "\C-c\C-au" 'markdown-insert-link)
;; Element removal
(define-key map (kbd "C-c C-k") 'markdown-kill-thing-at-point)
;; Promotion, Demotion, Completion, and Cycling
Expand All @@ -5502,7 +5503,7 @@ Assumes match data is available for `markdown-regex-italic'."
(define-key map (kbd "C-c C-]") 'markdown-complete)
;; Following and Jumping
(define-key map (kbd "C-c C-o") 'markdown-follow-thing-at-point)
(define-key map (kbd "C-c C-l") 'markdown-jump)
(define-key map (kbd "C-c C-d") 'markdown-jump)
;; Indentation
(define-key map (kbd "C-m") 'markdown-enter-key)
(define-key map (kbd "DEL") 'markdown-exdent-or-delete)
Expand Down

0 comments on commit 4835f37

Please sign in to comment.