<commit_before>;;; fuel-markup.el -- printing factor help markup

;; Copyright (C) 2009 <NAME>
;; See http://factorcode.org/license.txt for BSD license.

;; Author: <NAME> <<EMAIL>>
;; Keywords: languages, fuel, factor
;; Start date: Thu Jan 01, 2009 21:43

;;; Comentary:

;; Utilities for printing Factor's help markup.

;;; Code:

(require 'fuel-eval)
(require 'fuel-font-lock)
(require 'fuel-base)
(require 'fuel-table)

(require 'button)



;;; Customization:

(fuel-font-lock--defface fuel-font-lock-markup-title
  'bold fuel-help "article titles in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-heading
  'bold fuel-help "headlines in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-link
  'link fuel-help "links to topics in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-emphasis
  'italic fuel-help "emphasized words in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-strong
  'link fuel-help "bold words in help buffers")



;;; Links:

(make-variable-buffer-local
 (defvar fuel-markup--follow-link-function 'fuel-markup--echo-link))

(define-button-type 'fuel-markup--button
  'action 'fuel-markup--follow-link
  'face 'fuel-font-lock-markup-link
  'follow-link t)

(defun fuel-markup--follow-link (button)
  (when fuel-markup--follow-link-function
    (funcall fuel-markup--follow-link-function
             (button-get button 'markup-link)
             (button-get button 'markup-label)
             (button-get button 'markup-link-type))))

(defun fuel-markup--echo-link (link label type)
  (message "Link %s pointing to %s named %s" label type link))

(defun fuel-markup--insert-button (label link type)
  (let ((label (format "%s" label))
        (link (format "%s" link)))
    (insert-text-button label
                        :type 'fuel-markup--button
                        'markup-link link
                        'markup-label label
                        'markup-link-type type
                        'help-echo (format "%s (%s)" label type))))

(defun fuel-markup--article-title (name)
  (fuel-eval--retort-result
   (fuel-eval--send/wait `(:fuel* ((,name fuel-article-title :get)) "fuel"))))

(defun fuel-markup--link-at-point ()
  (let ((button (condition-case nil (forward-button 0) (error nil))))
    (when button
      (list (button-get button 'markup-link)
            (button-get button 'markup-label)
            (button-get button 'markup-link-type)))))



;;; Markup printers:

(defconst fuel-markup--printers
  '(($all-tags . fuel-markup--all-tags)
    ($all-authors . fuel-markup--all-authors)
    ($author . fuel-markup--author)
    ($authors . fuel-markup--authors)
    ($class-description . fuel-markup--class-description)
    ($code . fuel-markup--code)
    ($command . fuel-markup--command)
    ($command-map . fuel-markup--null)
    ($contract . fuel-markup--contract)
    ($curious . fuel-markup--curious)
    ($definition . fuel-markup--definition)
    ($describe-vocab . fuel-markup--describe-vocab)
    ($description . fuel-markup--description)
    ($doc-path . fuel-markup--doc-path)
    ($emphasis . fuel-markup--emphasis)
    ($error-description . fuel-markup--error-description)
    ($errors . fuel-markup--errors)
    ($example . fuel-markup--example)
    ($examples . fuel-markup--examples)
    ($heading . fuel-markup--heading)
    ($index . fuel-markup--index)
    ($instance . fuel-markup--instance)
    ($io-error . fuel-markup--io-error)
    ($link . fuel-markup--link)
    ($links . fuel-markup--links)
    ($list . fuel-markup--list)
    ($low-level-note . fuel-markup--low-level-note)
    ($markup-example . fuel-markup--markup-example)
    ($maybe . fuel-markup--maybe)
    ($methods . fuel-markup--methods)
    ($nl . fuel-markup--newline)
    ($notes . fuel-markup--notes)
    ($parsing-note . fuel-markup--parsing-note)
    ($predicate . fuel-markup--predicate)
    ($prettyprinting-note . fuel-markup--prettyprinting-note)
    ($quotation . fuel-markup--quotation)
    ($references . fuel-markup--references)
    ($related . fuel-markup--related)
    ($see . fuel-markup--see)<commit_msg>FUEL: $operation.<commit_after>;;; fuel-markup.el -- printing factor help markup

;; Copyright (C) 2009 <NAME>
;; See http://factorcode.org/license.txt for BSD license.

;; Author: <NAME> <<EMAIL>>
;; Keywords: languages, fuel, factor
;; Start date: Thu Jan 01, 2009 21:43

;;; Comentary:

;; Utilities for printing Factor's help markup.

;;; Code:

(require 'fuel-eval)
(require 'fuel-font-lock)
(require 'fuel-base)
(require 'fuel-table)

(require 'button)



;;; Customization:

(fuel-font-lock--defface fuel-font-lock-markup-title
  'bold fuel-help "article titles in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-heading
  'bold fuel-help "headlines in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-link
  'link fuel-help "links to topics in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-emphasis
  'italic fuel-help "emphasized words in help buffers")

(fuel-font-lock--defface fuel-font-lock-markup-strong
  'link fuel-help "bold words in help buffers")



;;; Links:

(make-variable-buffer-local
 (defvar fuel-markup--follow-link-function 'fuel-markup--echo-link))

(define-button-type 'fuel-markup--button
  'action 'fuel-markup--follow-link
  'face 'fuel-font-lock-markup-link
  'follow-link t)

(defun fuel-markup--follow-link (button)
  (when fuel-markup--follow-link-function
    (funcall fuel-markup--follow-link-function
             (button-get button 'markup-link)
             (button-get button 'markup-label)
             (button-get button 'markup-link-type))))

(defun fuel-markup--echo-link (link label type)
  (message "Link %s pointing to %s named %s" label type link))

(defun fuel-markup--insert-button (label link type)
  (let ((label (format "%s" label))
        (link (format "%s" link)))
    (insert-text-button label
                        :type 'fuel-markup--button
                        'markup-link link
                        'markup-label label
                        'markup-link-type type
                        'help-echo (format "%s (%s)" label type))))

(defun fuel-markup--article-title (name)
  (fuel-eval--retort-result
   (fuel-eval--send/wait `(:fuel* ((,name fuel-article-title :get)) "fuel"))))

(defun fuel-markup--link-at-point ()
  (let ((button (condition-case nil (forward-button 0) (error nil))))
    (when button
      (list (button-get button 'markup-link)
            (button-get button 'markup-label)
            (button-get button 'markup-link-type)))))



;;; Markup printers:

(defconst fuel-markup--printers
  '(($all-tags . fuel-markup--all-tags)
    ($all-authors . fuel-markup--all-authors)
    ($author . fuel-markup--author)
    ($authors . fuel-markup--authors)
    ($class-description . fuel-markup--class-description)
    ($code . fuel-markup--code)
    ($command . fuel-markup--command)
    ($command-map . fuel-markup--null)
    ($contract . fuel-markup--contract)
    ($curious . fuel-markup--curious)
    ($definition . fuel-markup--definition)
    ($describe-vocab . fuel-markup--describe-vocab)
    ($description . fuel-markup--description)
    ($doc-path . fuel-markup--doc-path)
    ($emphasis . fuel-markup--emphasis)
    ($error-description . fuel-markup--error-description)
    ($errors . fuel-markup--errors)
    ($example . fuel-markup--example)
    ($examples . fuel-markup--examples)
    ($heading . fuel-markup--heading)
    ($index . fuel-markup--index)
    ($instance . fuel-markup--instance)
    ($io-error . fuel-markup--io-error)
    ($link . fuel-markup--link)
    ($links . fuel-markup--links)
    ($list . fuel-markup--list)
    ($low-level-note . fuel-markup--low-level-note)
    ($markup-example . fuel-markup--markup-example)
    ($maybe . fuel-markup--maybe)
    ($methods . fuel-markup--methods)
    ($nl . fuel-markup--newline)
    ($notes . fuel-markup--notes)
    ($operation . fuel-markup--link)
    ($parsing-note . fuel-markup--parsing-note)
    ($predicate . fuel-markup--predicate)
    ($prettyprinting-note . fuel-markup--prettyprinting-note)
    ($quotation . fuel-markup--quotation)
    ($references . fuel-markup--references)
    ($related . fuel-markup--related)
    ($see . fuel-markup--see)
{'fraction_non_alphanumeric': 0.1663648436556803, 'fraction_numerical': 0.003621876131836291, 'mean_word_length': 2.7654545454545456, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1040304', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2741, 'n_words': 566}