[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-real a16fed2 032/160: Linting
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-real a16fed2 032/160: Linting |
Date: |
Wed, 6 Oct 2021 16:58:09 -0400 (EDT) |
branch: externals/org-real
commit a16fed264aaacd435d8d7b6dcf94882667b7720c
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>
Linting
---
org-real--box.el | 60 ++++++++++++++++++++++++++++----------------------------
org-real.el | 44 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 72 insertions(+), 32 deletions(-)
diff --git a/org-real--box.el b/org-real--box.el
index a988dc8..40b65e7 100644
--- a/org-real--box.el
+++ b/org-real--box.el
@@ -1,12 +1,22 @@
-;;; org-real.el --- Create org-mode links to real things -*- lexical-binding:
t -*-
+;;; org-real--box.el --- Create org-mode links to real things -*-
lexical-binding: t -*-
+
+;; Author: Tyler Grinn <tylergrinn@gmail.com>
+;; Version: 0.1.0
+;; File: org-real.el
+;; Package-Requires: ((emacs "26.1"))
+;; Keywords: tools
+;; URL: https://gitlab.com/tygrdev/org-real
;;; Commentary:
;; Box class definition and related methods
+;;; Code:
+
;;;; Patch! 0.0.1 -> 0.1.0+
;;;; Will be removed in version 1.0.0+
+(and (fboundp 'org-real--merge) (fmakunbound 'org-real--merge))
(and (fboundp 'org-real--map-immediate) (fmakunbound 'org-real--map-immediate))
(and (fboundp 'org-real--next) (fmakunbound 'org-real--next))
(and (fboundp 'org-real--merge-into) (fmakunbound 'org-real--merge-into))
@@ -24,12 +34,8 @@
(require 'eieio)
(require 'cl-lib)
-;;;; Class definitions
-;; Define empty class for use in collection, redefine afterwards
-;; (defclass org-real--box ()
- ;; nil
- ;; "A representation of a box in 3D space.")
+;;;; Class definitions
(defclass org-real--box-collection ()
((box :initarg :box
@@ -68,14 +74,6 @@
"A representation of a box in 3D space.")
-;;;; Constants
-
-(defvar org-real--padding '(2 . 1)
- "Padding used when displaying a real link.")
-
-(defvar org-real--margin '(2 . 1)
- "Margin used when displaying a real link.")
-
;;;; Exports
(cl-defmethod org-real--make-instance ((_ (subclass org-real--box)) containers)
@@ -93,7 +91,7 @@ property and optionally a :rel property."
(org-real--make-instance-helper containers world base))
world))
-(defun org-real--merge (boxes)
+(cl-defmethod org-real--merge (boxes)
"Merge BOXES into a single box."
(if (< (length boxes) 2)
(if (= 0 (length boxes))
@@ -128,12 +126,12 @@ OFFSET is the starting line to start insertion."
(draw (cons top left)
(concat "┌" (make-string (- width 2) (if dashed #x254c
#x2500)) "┐"))
(if align-bottom
- (draw (cons (+ top height -1 (cdr org-real--margin)) left)
+ (draw (cons (+ top height) left)
(concat "┴" (make-string (- width 2) (if dashed #x254c
#x2500)) "┴"))
(draw (cons (+ top height -1) left)
(concat "└" (make-string (- width 2) (if dashed #x254c
#x2500)) "┘")))
- (draw (cons (+ top 1 (cdr org-real--padding))
- (+ left 1 (car org-real--padding)))
+ (draw (cons (+ top 1 (cdr org-real-padding))
+ (+ left 1 (car org-real-padding)))
name
primary)
(let ((r (+ top 1))
@@ -150,7 +148,7 @@ OFFSET is the starting line to start insertion."
(cl-defmethod org-real--get-width ((box org-real--box))
"Get the width of BOX."
(let* ((base-width (+ 2 ; box walls
- (* 2 (car org-real--padding))))
+ (* 2 (car org-real-padding))))
(width (+ base-width
(if (slot-boundp box :name)
(with-slots (name) box (length name))
@@ -174,10 +172,10 @@ OFFSET is the starting line to start insertion."
columns))
(children-width (seq-reduce
(lambda (total width)
- (+ total (car org-real--margin) width))
+ (+ total (car org-real-margin) width))
column-widths
- (* -1 (car org-real--margin)))))
- (if (> width (+ (* 2 (car org-real--margin)) children-width))
+ (* -1 (car org-real-margin)))))
+ (if (> width (+ (* 2 (car org-real-margin)) children-width))
width
(+ base-width children-width))))))
@@ -185,11 +183,11 @@ OFFSET is the starting line to start insertion."
"Get the height of BOX."
(let* ((in-front (with-slots (in-front) box in-front))
(height (+ (if in-front
- (* -1 (cdr org-real--margin))
+ (* -1 (cdr org-real-margin))
0)
- 2 ; box walls
- (* 2 (cdr org-real--padding))
- (cdr org-real--margin)))
+ 3 ; box walls + text
+ (cdr org-real-padding)
+ (cdr org-real-margin)))
(children (with-slots (children) box (org-real--get-all children))))
(if (not children)
height
@@ -214,7 +212,7 @@ OFFSET is the starting line to start insertion."
(if (not (slot-boundp box :parent))
0
(with-slots (parent x-order y-order) box
- (let* ((offset (+ 1 (* 2 (cdr org-real--padding)) (cdr
org-real--margin)))
+ (let* ((offset (+ 2 (cdr org-real-padding) (cdr org-real-margin)))
(top (+ offset (org-real--get-top parent)))
(above (seq-filter
(lambda (child)
@@ -256,7 +254,7 @@ OFFSET is the starting line to start insertion."
0
(with-slots (parent x-order y-order) box
(let* ((left (+ 1
- (car org-real--padding)
+ (car org-real-padding)
(org-real--get-left parent)))
(to-the-left (seq-filter
(lambda (child)
@@ -277,7 +275,7 @@ OFFSET is the starting line to start insertion."
(if directly-left
(+ (org-real--get-left directly-left)
(org-real--get-width directly-left)
- (car org-real--margin))
+ (car org-real-margin))
(with-slots (rel rel-box) box
(if (and (slot-boundp box :rel)
(or (string= "above" rel)
@@ -295,7 +293,7 @@ OFFSET is the starting line to start insertion."
(cl-defmethod org-real--add-to-list ((collection org-real--box-collection)
(box org-real--box))
- "Add BOX to COLLECTION and return new COLLECTION"
+ "Add BOX to COLLECTION and return new COLLECTION."
(if (slot-boundp collection :box)
(org-real--box-collection
:box box
@@ -553,3 +551,5 @@ that the width of WORLD is kept below 80 characters if
possible."
(provide 'org-real--box)
+
+;;; org-real--box.el ends here
diff --git a/org-real.el b/org-real.el
index c721247..160379d 100644
--- a/org-real.el
+++ b/org-real.el
@@ -24,6 +24,24 @@
(require 'org-real--box)
+;;;; Customization variables
+
+(defcustom org-real-margin '(2 . 1)
+ "Margin to be used when displaying boxes.
+
+The first number is the horizontal margin, second is the vertical
+margin"
+ :type 'cons
+ :group 'org-real)
+
+(defcustom org-real-padding '(2 . 1)
+ "Padding to be used when displaying boxes.
+
+The first number is the horizontal padding, second is the
+vertical padding"
+ :type 'cons
+ :group 'org-real)
+
;;;; Faces
(defface org-real-primary
@@ -51,6 +69,28 @@
(reverse sequence))
nil)))
+(defun org-real--link-make-string (link &optional description)
+ "Make a bracket link, consisting of LINK and DESCRIPTION.
+LINK is escaped with backslashes for inclusion in buffer."
+ (let* ((zero-width-space (string ?\x200B))
+ (description
+ (and (org-string-nw-p description)
+ ;; Description cannot contain two consecutive square
+ ;; brackets, or end with a square bracket. To prevent
+ ;; this, insert a zero width space character between
+ ;; the brackets, or at the end of the description.
+ (replace-regexp-in-string
+ "\\(]\\)\\(]\\)"
+ (concat "\\1" zero-width-space "\\2")
+ (replace-regexp-in-string "]\\'"
+ (concat "\\&" zero-width-space)
+ (org-trim description))))))
+ (if (not (org-string-nw-p link)) description
+ (format "[[%s]%s]"
+ (org-link-escape link)
+ (if description (format "[%s]" description) "")))))
+
+
(defun org-real--parse-url (str)
"Parse STR into a list of plists.
@@ -205,7 +245,7 @@ ORIG is `org-insert-link', ARGS are the arguments passed to
it."
(advice-add 'org-insert-link :around #'org-real--maybe-edit-link)
(defun org-real--apply (&rest _)
- "Apply any changes to the current buffer if last inserted link is real."
+ "Apply any change to the current buffer if last inserted link is real."
(let (new-link replace-all)
(cond
((org-in-regexp org-link-bracket-re 1)
@@ -256,7 +296,7 @@ ORIG is `org-insert-link', ARGS are the arguments passed to
it."
`(lambda ()
(delete-region ,begin ,end)
(goto-char ,begin)
- (insert (org-link-make-string ,replace-link
,old-desc)))
+ (insert (org-real--link-make-string ,replace-link
,old-desc)))
changes))))))
(when (and changes
(or replace-all (let ((response
- [elpa] externals/org-real 8b3b5c2 005/160: org-real--merge and org-real-world, (continued)
- [elpa] externals/org-real 8b3b5c2 005/160: org-real--merge and org-real-world, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 883497d 009/160: Use .el file instead of .tar in release job, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real e039322 012/160: Add new line after pp text, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d557262 011/160: Switched to before and after advice for advising `org-insert-link', ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 1fa4417 015/160: Updated README, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real dfcddef 013/160: Added more documentation, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 9ea4553 018/160: Modified logic to allow multiple children, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real a909323 017/160: Shift other things to the right or below when merging, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 6fcc3b9 031/160: Updated md5 command to see tar files, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d07bf14 020/160: find-last index returns nil if no match, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real a16fed2 032/160: Linting,
ELPA Syncer <=
- [elpa] externals/org-real 9608f53 030/160: Satisfying elc compiler, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real dbd7b45 037/160: Check for compiler warnings in CI/CD pipeline, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 463da8b 029/160: Refactoring, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 6d8351f 038/160: Renamed org-real--box to org-real-box, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 4a569a1 039/160: Merge branch 'next' into 'main', ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d161250 041/160: Removed reference to org-real-box, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 9ac40b5 042/160: v0.1.0, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 181c538 043/160: Patch for using cl-defmethod rather than defun, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d81217c 045/160: Refactoring, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real cf2778a 049/160: Whitespace cleanup, ELPA Syncer, 2021/10/06