aboutsummaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/c-boxes.el407
-rw-r--r--custom/org-checklist.el5
-rw-r--r--custom/profile-dotemacs.el53
-rw-r--r--custom/titlecase-data.el92
-rw-r--r--custom/titlecase.el15
-rw-r--r--custom/utilities/vcf-conversion-helpers.el11
6 files changed, 27 insertions, 556 deletions
diff --git a/custom/c-boxes.el b/custom/c-boxes.el
deleted file mode 100644
index 273b783ab..000000000
--- a/custom/c-boxes.el
+++ /dev/null
@@ -1,407 +0,0 @@
-;;; Boxed comments for C mode.
-;;; Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-;;; Francois Pinard <pinard@iro.umontreal.ca>, April 1991.
-;;;
-;;; I often refill paragraphs inside C comments, while stretching or
-;;; shrinking the surrounding box as needed. This is a real pain to
-;;; do by hand. Here is the code I made to ease my life on this,
-;;; usable from within GNU Emacs. It would not be fair giving all
-;;; sources for a product without also giving the means for nicely
-;;; modifying them.
-;;;
-;;; The function rebox-c-comment adjust comment boxes without
-;;; refilling comment paragraphs, while reindent-c-comment adjust
-;;; comment boxes after refilling. Numeric prefixes are used to add,
-;;; remove, or change the style of the box surrounding the comment.
-;;; Since refilling paragraphs in C mode does make sense only for
-;;; comments, this code redefines the M-q command in C mode. I use
-;;; this hack by putting, in my .emacs file:
-;;;
-;;; (setq c-mode-hook
-;;; '(lambda ()
-;;; (define-key c-mode-map "\M-q" 'reindent-c-comment)))
-;;; (autoload 'rebox-c-comment "c-boxes" nil t)
-;;; (autoload 'reindent-c-comment "c-boxes" nil t)
-;;;
-;;; The cursor should be within a comment before any of these
-;;; commands, or else it should be between two comments, in which case
-;;; the command applies to the next comment. When the command is
-;;; given without prefix, the current comment box type is recognized
-;;; and preserved. Given 0 as a prefix, the comment box disappears
-;;; and the comment stays between a single opening `/*' and a single
-;;; closing `*/'. Given 1 or 2 as a prefix, a single or doubled lined
-;;; comment box is forced. Given 3 as a prefix, a Taarna style box is
-;;; forced, but you do not even want to hear about those. When a
-;;; negative prefix is given, the absolute value is used, but the
-;;; default style is changed. Any other value (like C-u alone) forces
-;;; the default box style.
-;;;
-;;; I observed rounded corners first in some code from Warren Tucker
-;;; <wht@n4hgf.mt-park.ga.us>.
-
-(defvar c-box-default-style 'single "*Preferred style for box comments.")
-(defvar c-mode-taarna-style nil "*Non-nil for Taarna team C-style.")
-
-;;; Set or reset the Taarna team's own way for a C style.
-
-(defun taarna-mode ()
- (interactive)
- (if c-mode-taarna-style
- (progn
-
- (setq c-mode-taarna-style nil)
- (setq c-indent-level 2)
- (setq c-continued-statement-offset 2)
- (setq c-brace-offset 0)
- (setq c-argdecl-indent 5)
- (setq c-label-offset -2)
- (setq c-tab-always-indent t)
- (setq c-box-default-style 'single)
- (message "C mode: GNU style"))
-
- (setq c-mode-taarna-style t)
- (setq c-indent-level 4)
- (setq c-continued-statement-offset 4)
- (setq c-brace-offset -4)
- (setq c-argdecl-indent 4)
- (setq c-label-offset -4)
- (setq c-tab-always-indent t)
- (setq c-box-default-style 'taarna)
- (message "C mode: Taarna style")))
-
-;;; Return the minimum value of the left margin of all lines, or -1 if
-;;; all lines are empty.
-
-(defun buffer-left-margin ()
- (let ((margin -1))
- (goto-char (point-min))
- (while (not (eobp))
- (skip-chars-forward " \t")
- (if (not (looking-at "\n"))
- (setq margin
- (if (< margin 0)
- (current-column)
- (min margin (current-column)))))
- (forward-line 1))
- margin))
-
-;;; Return the maximum value of the right margin of all lines. Any
-;;; sentence ending a line has a space guaranteed before the margin.
-
-(defun buffer-right-margin ()
- (let ((margin 0) period)
- (goto-char (point-min))
- (while (not (eobp))
- (end-of-line)
- (if (bobp)
- (setq period 0)
- (backward-char 1)
- (setq period (if (looking-at "[.?!]") 1 0))
- (forward-char 1))
- (setq margin (max margin (+ (current-column) period)))
- (forward-char 1))
- margin))
-
-;;; Add, delete or adjust a C comment box. If FLAG is nil, the
-;;; current boxing style is recognized and preserved. When 0, the box
-;;; is removed; when 1, a single lined box is forced; when 2, a double
-;;; lined box is forced; when 3, a Taarna style box is forced. If
-;;; negative, the absolute value is used, but the default style is
-;;; changed. For any other value (like C-u), the default style is
-;;; forced. If REFILL is not nil, refill the comment paragraphs prior
-;;; to reboxing.
-
-(defun rebox-c-comment-engine (flag refill)
- (save-restriction
- (let ((undo-list buffer-undo-list)
- (marked-point (point-marker))
- (saved-point (point))
- box-style left-margin right-margin)
-
- ;; First, find the limits of the block of comments following or
- ;; enclosing the cursor, or return an error if the cursor is not
- ;; within such a block of comments, narrow the buffer, and
- ;; untabify it.
-
- ;; - insure the point is into the following comment, if any
-
- (skip-chars-forward " \t\n")
- (if (looking-at "/\\*")
- (forward-char 2))
-
- (let ((here (point)) start end temp)
-
- ;; - identify a minimal comment block
-
- (search-backward "/*")
- (setq temp (point))
- (beginning-of-line)
- (setq start (point))
- (skip-chars-forward " \t")
- (if (< (point) temp)
- (progn
- (goto-char saved-point)
- (error "text before comment's start")))
- (search-forward "*/")
- (setq temp (point))
- (end-of-line)
- (if (looking-at "\n")
- (forward-char 1))
- (setq end (point))
- (skip-chars-backward " \t\n")
- (if (> (point) temp)
- (progn
- (goto-char saved-point)
- (error "text after comment's end")))
- (if (< end here)
- (progn
- (goto-char saved-point)
- (error "outside any comment block")))
-
- ;; - try to extend the comment block backwards
-
- (goto-char start)
- (while (and (not (bobp))
- (progn (previous-line 1)
- (beginning-of-line)
- (looking-at "[ \t]*/\\*.*\\*/[ \t]*$")))
- (setq start (point)))
-
- ;; - try to extend the comment block forward
-
- (goto-char end)
- (while (looking-at "[ \t]*/\\*.*\\*/[ \t]*$")
- (forward-line 1)
- (beginning-of-line)
- (setq end (point)))
-
- ;; - narrow to the whole block of comments
-
- (narrow-to-region start end))
-
- ;; Second, remove all the comment marks, and move all the text
- ;; rigidly to the left to insure the left margin stays at the
- ;; same place. At the same time, recognize and save the box
- ;; style in BOX-STYLE.
-
- (let ((previous-margin (buffer-left-margin))
- actual-margin)
-
- ;; - remove all comment marks
-
- (goto-char (point-min))
- (replace-regexp "^\\([ \t]*\\)/\\*" "\\1 ")
- (goto-char (point-min))
- (replace-regexp "^\\([ \t]*\\)|" "\\1 ")
- (goto-char (point-min))
- (replace-regexp "\\(\\*/\\||\\)[ \t]*" "")
- (goto-char (point-min))
- (replace-regexp "\\*/[ \t]*/\\*" " ")
-
- ;; - remove the first and last dashed lines
-
- (setq box-style 'plain)
- (goto-char (point-min))
- (if (looking-at "^[ \t]*-*[.\+\\]?[ \t]*\n")
- (progn
- (setq box-style 'single)
- (replace-match ""))
- (if (looking-at "^[ \t]*=*[.\+\\]?[ \t]*\n")
- (progn
- (setq box-style 'double)
- (replace-match ""))))
- (goto-char (point-max))
- (previous-line 1)
- (beginning-of-line)
- (if (looking-at "^[ \t]*[`\+\\]?*[-=]+[ \t]*\n")
- (progn
- (if (eq box-style 'plain)
- (setq box-style 'taarna))
- (replace-match "")))
-
- ;; - remove all spurious whitespace
-
- (goto-char (point-min))
- (replace-regexp "[ \t]+$" "")
- (goto-char (point-min))
- (if (looking-at "\n+")
- (replace-match ""))
- (goto-char (point-max))
- (skip-chars-backward "\n")
- (if (looking-at "\n\n+")
- (replace-match "\n"))
- (goto-char (point-min))
- (replace-regexp "\n\n\n+" "\n\n")
-
- ;; - move the text left is adequate
-
- (setq actual-margin (buffer-left-margin))
- (if (not (= previous-margin actual-margin))
- (indent-rigidly (point-min) (point-max)
- (- previous-margin actual-margin))))
-
- ;; Third, select the new box style from the old box style and
- ;; the argument, choose the margins for this style and refill
- ;; each paragraph.
-
- ;; - modify box-style only if flag is defined
-
- (if flag
- (setq box-style
- (cond ((eq flag 0) 'plain)
- ((eq flag 1) 'single)
- ((eq flag 2) 'double)
- ((eq flag 3) 'taarna)
- ((eq flag '-) (setq c-box-default-style 'plain) 'plain)
- ((eq flag -1) (setq c-box-default-style 'single) 'single)
- ((eq flag -2) (setq c-box-default-style 'double) 'double)
- ((eq flag -3) (setq c-box-default-style 'taarna) 'taarna)
- (t c-box-default-style))))
-
- ;; - compute the left margin
-
- (setq left-margin (buffer-left-margin))
-
- ;; - temporarily set the fill prefix and column, then refill
-
- (untabify (point-min) (point-max))
-
- (if refill
- (let ((fill-prefix (make-string left-margin ? ))
- (fill-column (- fill-column
- (if (memq box-style '(single double)) 4 6))))
- (fill-region (point-min) (point-max))))
-
- ;; - compute the right margin after refill
-
- (setq right-margin (buffer-right-margin))
-
- ;; Fourth, put the narrowed buffer back into a comment box,
- ;; according to the value of box-style. Values may be:
- ;; plain: insert between a single pair of comment delimiters
- ;; single: complete box, overline and underline with dashes
- ;; double: complete box, overline and underline with equal signs
- ;; taarna: comment delimiters on each line, underline with dashes
-
- ;; - move the right margin to account for left inserts
-
- (setq right-margin (+ right-margin
- (if (memq box-style '(single double))
- 2
- 3)))
-
- ;; - construct the box comment, from top to bottom
-
- (goto-char (point-min))
- (cond ((eq box-style 'plain)
-
- ;; - construct a plain style comment
-
- (skip-chars-forward " " (+ (point) left-margin))
- (insert (make-string (- left-margin (current-column)) ? )
- "/* ")
- (end-of-line)
- (forward-char 1)
- (while (not (eobp))
- (skip-chars-forward " " (+ (point) left-margin))
- (insert (make-string (- left-margin (current-column)) ? )
- " ")
- (end-of-line)
- (forward-char 1))
- (backward-char 1)
- (insert " */"))
- ((eq box-style 'single)
-
- ;; - construct a single line style comment
-
- (indent-to left-margin)
- (insert "/*")
- (insert (make-string (- right-margin (current-column)) ?-)
- "-.\n")
- (while (not (eobp))
- (skip-chars-forward " " (+ (point) left-margin))
- (insert (make-string (- left-margin (current-column)) ? )
- "| ")
- (end-of-line)
- (indent-to right-margin)
- (insert " |")
- (forward-char 1))
- (indent-to left-margin)
- (insert "`")
- (insert (make-string (- right-margin (current-column)) ?-)
- "*/\n"))
- ((eq box-style 'double)
-
- ;; - construct a double line style comment
-
- (indent-to left-margin)
- (insert "/*")
- (insert (make-string (- right-margin (current-column)) ?=)
- "=\\\n")
- (while (not (eobp))
- (skip-chars-forward " " (+ (point) left-margin))
- (insert (make-string (- left-margin (current-column)) ? )
- "| ")
- (end-of-line)
- (indent-to right-margin)
- (insert " |")
- (forward-char 1))
- (indent-to left-margin)
- (insert "\\")
- (insert (make-string (- right-margin (current-column)) ?=)
- "*/\n"))
- ((eq box-style 'taarna)
-
- ;; - construct a Taarna style comment
-
- (while (not (eobp))
- (skip-chars-forward " " (+ (point) left-margin))
- (insert (make-string (- left-margin (current-column)) ? )
- "/* ")
- (end-of-line)
- (indent-to right-margin)
- (insert " */")
- (forward-char 1))
- (indent-to left-margin)
- (insert "/* ")
- (insert (make-string (- right-margin (current-column)) ?-)
- " */\n"))
- (t (error "unknown box style")))
-
- ;; Fifth, retabify, restore the point position, then cleanup the
- ;; undo list of any boundary since we started.
-
- ;; - retabify before left margin only (adapted from tabify.el)
-
- (goto-char (point-min))
- (while (re-search-forward "^[ \t][ \t][ \t]*" nil t)
- (let ((column (current-column))
- (indent-tabs-mode t))
- (delete-region (match-beginning 0) (point))
- (indent-to column)))
-
- ;; - restore the point position
-
- (goto-char (marker-position marked-point))
-
- ;; - remove all intermediate boundaries from the undo list
-
- (if (not (eq buffer-undo-list undo-list))
- (let ((cursor buffer-undo-list))
- (while (not (eq (cdr cursor) undo-list))
- (if (car (cdr cursor))
- (setq cursor (cdr cursor))
- (rplacd cursor (cdr (cdr cursor))))))))))
-
-;;; Rebox a C comment without refilling it.
-
-(defun rebox-c-comment (flag)
- (interactive "P")
- (rebox-c-comment-engine flag nil))
-
-;;; Rebox a C comment after refilling.
-
-(defun reindent-c-comment (flag)
- (interactive "P")
- (rebox-c-comment-engine flag t))
-
diff --git a/custom/org-checklist.el b/custom/org-checklist.el
index e7d9b4682..170f449e6 100644
--- a/custom/org-checklist.el
+++ b/custom/org-checklist.el
@@ -47,9 +47,8 @@
;;; Code:
(require 'org)
(defvar org-state)
-;; FIXME: This library requires
-;; https://git.savannah.gnu.org/cgit/a2ps.git/tree/contrib/emacs/a2ps-print.el file
-;; It is a part of a2ps distribution.
+;; Optional print support: a2ps-print.el ships with a2ps. Without it, checklist
+;; reset/export still works, but print commands that call a2ps-buffer are absent.
(load "a2ps-print" 'no-error)
(defvar a2ps-switches)
(declare-function a2ps-buffer "a2ps-print" (argp))
diff --git a/custom/profile-dotemacs.el b/custom/profile-dotemacs.el
index f16e8652f..8baee47b2 100644
--- a/custom/profile-dotemacs.el
+++ b/custom/profile-dotemacs.el
@@ -20,55 +20,16 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
-
-;; This is to easily profile your Emacs init file (or any other
-;; script-like Emacs Lisp file, for that matter).
-
-;; It will go over all sexp's (balanced expressions) in the file and
-;; run them through `benchmark-run'. It will then show the file with
-;; overlays applied in a way that let you easily find out which sexp's
-;; take the most time. Since time is relative, it's not the absolute
-;; value that counts but the percentage of the total running time.
;;
-;; * All other sexp's with a percentage greater than
-;; `profile-dotemacs-low-percentage' will be preceded by a
-;; highlighted line, showing the results from `benchmark-run'.
-;; Also, the more 'reddish' the background of the sexp, the more
-;; time it needs.
-
-;; * All other sexp's will be grayed out to indicate that their
-;; running time is miniscule. You can still see the benchmark
-;; results in the minibuffer by hovering over the sexp with the
-;; mouse.
-
-;; You can only benchmark full sexp's, so if you wrapped large parts
-;; of your init file in some conditional clause, you'll have to remove
-;; that for getting finer granularity.
-
-;;; Usage:
-
-;; Start emacs as follows:
+;; Profiles profile-dotemacs-file by evaluating top-level sexps with
+;; benchmark-run, then overlays the source buffer so expensive forms stand out
+;; by percentage of total runtime.
;;
-;; emacs -Q -l <PATH>/profile-dotemacs.el -f profile-dotemacs
+;; Run with:
+;; emacs -Q -l /path/to/profile-dotemacs.el -f profile-dotemacs
;;
-;; with <PATH> being the path to where this file resides.
-
-;;; Caveats (thanks to Raffaele Ricciardi for reporting those):
-
-;; - The usual `--debug-init' for debugging your init file won't work
-;; with profile-dotemacs, so you'll have to call
-;; `toggle-debug-on-error', either on the commandline or at the
-;; beginning of your init file.
-;; - `load-file-name' is nil when the init file is being loaded
-;; by the profiler. This might matter if you perform the
-;; bulk of initializations in a different file.
-;; - Starting external shells like IELM or eshell in your init file
-;; might mess with overlay creation, so this must not be done.
-
-;;; Download:
-
-;; You can always get the latest version from
-;; http://randomsample.de/profile-dotemacs.el
+;; Full sexps are the unit of measurement; split large conditional blocks before
+;; profiling if finer detail is needed.
;;; Code:
diff --git a/custom/titlecase-data.el b/custom/titlecase-data.el
index a64685861..7415a2104 100644
--- a/custom/titlecase-data.el
+++ b/custom/titlecase-data.el
@@ -18,91 +18,13 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
-
-;; Since the `titlecase' package requires a lot of data, that data lives here so
-;; as to not clog up the main package.
-
-;; Since [[https://github.com/duckwork/titlecase.el/issues/23][Issue #23]] makes
-;; a good point that I should like, make more sense in the commentary and README
-;; of this repository. At the same time, those couple of comments I wrote in
-;; there I don't want to just /delete/, so until I write this up in a proper
-;; blog post, I've included it here, in the data file, because this is where
-;; these implementation notes will be of most interest.
-
-;; The only setting you really should need to set is =titlecase-style=, which
-;; see. Each of these styles has a different set of rules regarding which words
-;; to capitalize in a title. After you've set =titlecase-style=, you can bind
-;; the command =titlecase-dwim= to a key, or call it using M-x, and it will
-;; either title-case your region (if it's active) or the current line.
-
-;; The tricky part is figuring out what words to capitalize in the title.
-
-;; Articles (~a~, ~an~, ~the~) are downcased.
-
-;; The first word of a title and all "important words" (generally nouns,
-;; pronouns, adjectives, verbs, and adverbs) are capitalized. The last word of
-;; a title is always capitalized, but only in Chicago, AP, Bluebook, AMA, NY
-;; Times, and Wikipedia.
-
-;; /All/ prepositions are downcased in Chicago, MLA, AP, NY Times, and
-;; Wikipedia, regardless of length; for APA, Bluebook, AMA, and Wikipedia, only
-;; prepositions shorter than 5 letters are (presumably, capitalize those longer
-;; than 5 letters, however only Wikipedia was clear on that point).
-
-;; Coordinating conjunctions are capitalized in Chicago and APA (presumably),
-;; but downcased in MLA, AP, Bluebook, AMA, NY Times, and Wikipedia.
-
-;; Hyphenated words are tricky: I could possibly figure out a way to have lookup
-;; tables to determine when to capitalize the second part of a hyphenated word,
-;; but I haven't implemented them yet. At any rate, the rules tend to be vague
-;; enough that it's hard to program anyway: For example, Chicago, APA, MLA, and
-;; AP lowercase the second word "after a hyphenated prefix (e.g., Mid-, Anti-,
-;; Super, etc.) in compound modifiers," but MLA and APA capitalize the second
-;; part of "hyphenated major words (e.g., Self-Report not Self-report).
-
-;; Perhaps unsurprisingly, the AMA (American Medical Association, used in the
-;; scientific community) has the most comprehensive capitalization rules around
-;; hyphenated words. I'll just copy-paste the bullet points here:
-
-;; - Lowercase the second word in a hyphenated compound when it is
-;; a prefix or suffix (e.g., "Anti-itch","world-wide") or part of a single word.
-;; - Capitalize the second word in a hyphenated compound if both words are equal
-;; and not suffices or prefixes (e.g., "Cost-Benefit")
-;; - Capitalize the first non-Greek letter after a lowercase Greek letter (e.g.,
-;; "ω-Bromohexanoic")
-;; - Lowercase the first non-Greek letter after a capital Greek letter (e.g.,
-;; "Δ-9-tetrahydrocannabinol") #+end_quote
-
-;; (The AMA also has a rule about capitilizing the genus but not species
-;; epithet, but the lookup on that would be wild as hell, so I trust yall to
-;; know on that one.)
-
-;; ~To~ as an infinitive is downcased in all /except/ AP. This is a rule I
-;; simply cannot implement without knowing whether the /next/ word is a verb,
-;; which would require expensive lookups, which even then wouldn't be foolproof.
-
-;; Now that I'm thinking about it, most styles count phrasal verbs (like "play
-;; with") as important enough to capitalize, when "with" would usually /not/ be
-;; capitalized, but again, open categories like phrasal verbs simply do not work
-;; in a package like this.
-
-;; ALL OF THIS IS TO SAY that titlecase offers a best-effort attempt to
-;; titlecase a line or region of text, but you should absolutely
-;; double-triple-check against the style guide you're writing for if you're
-;; trying for publication or something like that.
-
-;; SEE ALSO:
-
-;; Prior art:
-
-;; - https://emacs.stackexchange.com/questions/66361/#66362
-;; - https://github.com/novoid/title-capitalization.el
-;; - https://hungyi.net/posts/programmers-way-to-title-case/
-
-;; Rules:
-
-;; - https://capitalizemytitle.com/#capitalizationrules
-;; - https://titlecaseconverter.com/rules/
+;;
+;; Data tables for titlecase.el: style-specific lowercase word lists, phrasal
+;; verbs, and exceptions used by the title-casing engine.
+;;
+;; Title casing is best-effort because English style guides disagree and some
+;; cases require grammatical knowledge this package does not model. Proofread
+;; output before publication.
;;; Code:
diff --git a/custom/titlecase.el b/custom/titlecase.el
index 439478220..319befefd 100644
--- a/custom/titlecase.el
+++ b/custom/titlecase.el
@@ -175,7 +175,8 @@ for docs on BEGIN, END and STYLE."
titlecase-skip-words-regexps
"\\|")))
(goto-char (match-end 0))
- ;; TODO: Document what this does (it's late)
+ ;; If the skip regexp consumed the final word, exit before the main loop tries
+ ;; to advance past END.
(when (>= (point) end)
(throw :done 'skipped)))
;; Phrasal verbs!
@@ -210,16 +211,8 @@ for docs on BEGIN, END and STYLE."
((and (memq style titlecase-styles-capitalize-non-short-words)
(> (length this-word) titlecase-short-word-length))
(capitalize-word 1))
- ;; Sentence style just capitalizes the first word. Since we can't be
- ;; sure how the user has already capitalized anything, we just skip
- ;; the current word. HOWEVER, there are times when downcasing the
- ;; rest of the sentence is warranted. --- NOTE 2022-05-09: Now I'm
- ;; thinking about it, does `sentence' style need to do anything
- ;; whatsoever? Maybe I just need to include a test toward the top of
- ;; the enclosing function to make `titlecase-default-case-function'
- ;; be `downcase-word' if `titlecase-downcase-sentences' is true... or
- ;; something of that nature. I might be over-engineering this, is
- ;; what I'm saying. Curious, isn't it?
+ ;; Sentence style either leaves later words unchanged or downcases them,
+ ;; depending on titlecase-downcase-sentences.
((eq style 'sentence)
(funcall (if titlecase-downcase-sentences
#'downcase-word
diff --git a/custom/utilities/vcf-conversion-helpers.el b/custom/utilities/vcf-conversion-helpers.el
index 334edc4e2..4ea340236 100644
--- a/custom/utilities/vcf-conversion-helpers.el
+++ b/custom/utilities/vcf-conversion-helpers.el
@@ -2,6 +2,9 @@
;;; Commentary:
;;
+;; Helpers for converting exported VCF contacts into org-contacts data. The
+;; cleaner normalizes folded fields, birthdays, item-prefixed email/phone fields,
+;; and removes cards without useful identifying data before import.
;;; Code:
@@ -12,8 +15,8 @@
(insert-file-contents input-vcf)
(goto-char (point-min))
- ;; First, clean up multi-line fields (unfold them) BEFORE processing
- ;; This ensures PHOTO and other multi-line fields are on single lines
+ ;; Unfold continuation lines before field-level parsing; PHOTO and NOTE values
+ ;; often span multiple physical lines in exported VCF files.
(goto-char (point-min))
(while (re-search-forward "\n[ \t]+" nil t)
(replace-match " " t t))
@@ -57,7 +60,7 @@
(field-value (match-string 3)))
(replace-match (format "%s%s:%s" field-type field-params field-value) t t)))
- ;; NOW remove unwanted fields (but not the converted TEL/EMAIL fields)
+ ;; Remove Apple/Google metadata fields after preserving converted TEL/EMAIL data.
(let ((remove-patterns
'("^PHOTO:.*$"
"^X-ABRELATEDNAMES:.*$"
@@ -153,7 +156,7 @@
(widen)))))))
- ;; Remove VCARDs with no identifying information (in reverse order to preserve positions)
+ ;; Drop cards with no displayable name, in reverse order to keep positions valid.
(dolist (vcard-range (reverse vcards-to-remove))
(delete-region (car vcard-range) (cdr vcard-range))
(message "Removed VCARD with no identifying information")))