branch: elpa/fedi
commit f1ddae4b72dd4683e8df609703411405d43fe57b
Merge: 924180a4ef4 e86f0f9d6f7
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    Merge branch 'dev'
---
 fedi-iso.el  | 245 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fedi-post.el |  41 +++++-----
 2 files changed, 266 insertions(+), 20 deletions(-)

diff --git a/fedi-iso.el b/fedi-iso.el
new file mode 100644
index 00000000000..6c5545155fb
--- /dev/null
+++ b/fedi-iso.el
@@ -0,0 +1,245 @@
+;;; fedi-iso.el --- ISO language code lists for fedi.el  -*- lexical-binding: 
t -*-
+
+;; Copyright (C) 2022 Marty Hiatt
+;; Author: Marty Hiatt <[email protected]>
+;; Version: 1.0.0
+;; Homepage: https://codeberg.org/martianh/fedi.el
+
+;; This file is not part of GNU Emacs.
+
+;; This file is part of fedi.el.
+
+;; fedi.el is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; fedi.el is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with fedi.el.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+;; via
+;; 
https://github.com/VyrCossont/mastodon/blob/0836f4a656d5486784cadfd7d0cd717bb67ede4c/app/helpers/languages_helper.rb
+;; and
+;; https://github.com/Shinmera/language-codes/blob/master/data/iso-639-3.lisp
+
+(defvar fedi-iso-639-1
+  '(("Abkhazian" . "ab")
+    ("Afar" . "aa")
+    ("Afrikaans" . "af")
+    ("Akan" . "ak")
+    ("Albanian" . "sq")
+    ("Amharic" . "am")
+    ("Arabic" . "ar")
+    ("Aragonese" . "an")
+    ("Armenian" . "hy")
+    ("Assamese" . "as")
+    ("Avaric" . "av")
+    ("Avestan" . "ae")
+    ("Aymara" . "ay")
+    ("Azerbaijani" . "az")
+    ("Bambara" . "bm")
+    ("Bashkir" . "ba")
+    ("Basque" . "eu")
+    ("Belarusian" . "be")
+    ("Bengali" . "bn")
+    ("Bihari languages" . "bh")
+    ("Bislama" . "bi")
+    ("Bosnian" . "bs")
+    ("Breton" . "br")
+    ("Bulgarian" . "bg")
+    ("Burmese" . "my")
+    ("Central Khmer" . "km")
+    ("Chamorro" . "ch")
+    ("Chechen" . "ce")
+    ("Chinese" . "zh")
+    ("Chuvash" . "cv")
+    ("Cornish" . "kw")
+    ("Corsican" . "co")
+    ("Cree" . "cr")
+    ("Croatian" . "hr")
+    ("Czech" . "cs")
+    ("Danish" . "da")
+    ("Dzongkha" . "dz")
+    ("English" . "en")
+    ("Esperanto" . "eo")
+    ("Estonian" . "et")
+    ("Ewe" . "ee")
+    ("Faroese" . "fo")
+    ("Fijian" . "fj")
+    ("Finnish" . "fi")
+    ("Dutch" . "nl")
+    ("French" . "fr")
+    ("Fulah" . "ff")
+    ("Galician" . "gl")
+    ("Ganda" . "lg")
+    ("Georgian" . "ka")
+    ("German" . "de")
+    ("Greek" . "el")
+    ("Guarani" . "gn")
+    ("Gujarati" . "gu")
+    ("Haitian" . "ht")
+    ("Hausa" . "ha")
+    ("Hebrew" . "he")
+    ("Herero" . "hz")
+    ("Hindi" . "hi")
+    ("Hiri Motu" . "ho")
+    ("Hungarian" . "hu")
+    ("Icelandic" . "is")
+    ("Ido" . "io")
+    ("Igbo" . "ig")
+    ("Indonesian" . "id")
+    ("Interlingua" . "ia")
+    ("Inuktitut" . "iu")
+    ("Inupiaq" . "ik")
+    ("Irish" . "ga")
+    ("Italian" . "it")
+    ("Japanese" . "ja")
+    ("Japanese" . "jp")
+    ("Javanese" . "jv")
+    ("Kalaallisut" . "kl")
+    ("Kannada" . "kn")
+    ("Kanuri" . "kr")
+    ("Kashmiri" . "ks")
+    ("Kazakh" . "kk")
+    ("Kikuyu" . "ki")
+    ("Kinyarwanda" . "rw")
+    ("Komi" . "kv")
+    ("Kongo" . "kg")
+    ("Korean" . "ko")
+    ("Kurdish" . "ku")
+    ("Kuanyama" . "kj")
+    ("Kirghiz" . "ky")
+    ("Lao" . "lo")
+    ("Latin" . "la")
+    ("Latvian" . "lv")
+    ("Limburgan" . "li")
+    ("Lingala" . "ln")
+    ("Lithuanian" . "lt")
+    ("Luba-Katanga" . "lu")
+    ("Luxembourgish" . "lb")
+    ("Macedonian" . "mk")
+    ("Malagasy" . "mg")
+    ("Malay" . "ms")
+    ("Malayalam" . "ml")
+    ("Divehi" . "dv")
+    ("Maltese" . "mt")
+    ("Manx" . "gv")
+    ("Maori" . "mi")
+    ("Marathi" . "mr")
+    ("Marshallese" . "mh")
+    ("Mongolian" . "mn")
+    ("Nauru" . "na")
+    ("Navajo" . "nv")
+    ("Ndonga" . "ng")
+    ("Nepali" . "ne")
+    ("Ndebele, North" . "nd")
+    ("Northern Sami" . "se")
+    ("Norwegian" . "no")
+    ("Bokmål, Norwegian" . "nb")
+    ("Chichewa" . "ny")
+    ("Norwegian Nynorsk" . "nn")
+    ("Interlingue" . "ie")
+    ("Occitan" . "oc")
+    ("Ojibwa" . "oj")
+    ("Church Slavic" . "cu")
+    ("Oriya" . "or")
+    ("Oromo" . "om")
+    ("Ossetian" . "os")
+    ("Pali" . "pi")
+    ("Persian" . "fa")
+    ("Polish" . "pl")
+    ("Portuguese" . "pt")
+    ("Panjabi" . "pa")
+    ("Pushto" . "ps")
+    ("Quechua" . "qu")
+    ("Romanian" . "ro")
+    ("Romansh" . "rm")
+    ("Rundi" . "rn")
+    ("Russian" . "ru")
+    ("Samoan" . "sm")
+    ("Sango" . "sg")
+    ("Sanskrit" . "sa")
+    ("Sardinian" . "sc")
+    ("Gaelic" . "gd")
+    ("Serbian" . "sr")
+    ("Shona" . "sn")
+    ("Sichuan Yi" . "ii")
+    ("Sindhi" . "sd")
+    ("Sinhala" . "si")
+    ("Slovak" . "sk")
+    ("Slovenian" . "sl")
+    ("Somali" . "so")
+    ("Sotho, Southern" . "st")
+    ("Ndebele, South" . "nr")
+    ("Spanish" . "es")
+    ("Sundanese" . "su")
+    ("Swahili" . "sw")
+    ("Swati" . "ss")
+    ("Swedish" . "sv")
+    ("Tagalog" . "tl")
+    ("Tahitian" . "ty")
+    ("Tajik" . "tg")
+    ("Tamil" . "ta")
+    ("Tatar" . "tt")
+    ("Telugu" . "te")
+    ("Thai" . "th")
+    ("Tibetan" . "bo")
+    ("Tigrinya" . "ti")
+    ("Tonga (Tonga Islands)" . "to")
+    ("Tsonga" . "ts")
+    ("Tswana" . "tn")
+    ("Turkish" . "tr")
+    ("Turkmen" . "tk")
+    ("Twi" . "tw")
+    ("Ukrainian" . "uk")
+    ("Urdu" . "ur")
+    ("Uighur" . "ug")
+    ("Uzbek" . "uz")
+    ("Catalan" . "ca")
+    ("Venda" . "ve")
+    ("Vietnamese" . "vi")
+    ("Volapük" . "vo")
+    ("Walloon" . "wa")
+    ("Welsh" . "cy")
+    ("Western Frisian" . "fy")
+    ("Wolof" . "wo")
+    ("Xhosa" . "xh")
+    ("Yiddish" . "yi")
+    ("Yoruba" . "yo")
+    ("Zhuang" . "za")
+    ("Zulu" . "zu")))
+
+;; web UI doesn't respect these for now
+(defvar fedi-iso-639-regional
+  '(("es-AR" "Español (Argentina)")
+    ("es-MX" "Español (México)")
+    ("pt-BR" "Português (Brasil)")
+    ("pt-PT" "Português (Portugal)")
+    ("sr-Latn" "Srpski (latinica)")
+    ("zh-CN" "简体中文")
+    ("zh-HK" "繁體中文(香港)")
+    ("zh-TW" "繁體中文(臺灣)")))
+
+(defvar fedi-iso-639-3
+  '(("ast" "Asturian" "Asturianu")
+    ("ckb" "Sorani (Kurdish)" "سۆرانی")
+    ("jbo" "Lojban" "la .lojban.")
+    ("kab" "Kabyle" "Taqbaylit")
+    ("kmr" "Kurmanji (Kurdish)" "Kurmancî")
+    ("ldn" "Láadan" "Láadan")
+    ("lfn" "Lingua Franca Nova" "lingua franca nova")
+    ("tok" "Toki Pona" "toki pona")
+    ("zba" "Balaibalan" "باليبلن")
+    ("zgh" "Standard Moroccan Tamazight" "ⵜⴰⵎⴰⵣⵉⵖⵜ")))
+
+(provide 'fedi-iso)
+;;; fedi-iso.el ends here
diff --git a/fedi-post.el b/fedi-post.el
index 31bc3a46ee3..4da2db47b87 100644
--- a/fedi-post.el
+++ b/fedi-post.el
@@ -10,18 +10,18 @@
 
 ;; This file is part of fedi.el.
 
-;; mastodon.el is free software: you can redistribute it and/or modify
+;; fedi.el is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; mastodon.el is distributed in the hope that it will be useful,
+;; fedi.el is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with mastodon.el.  If not, see <http://www.gnu.org/licenses/>.
+;; along with fedi.el.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -42,6 +42,8 @@
 (require 'text-property-search)
 (require 'markdown-mode)
 
+(require 'fedi-iso)
+
 (autoload 'iso8601-parse "iso8601")
 (autoload 'fedi--find-property-range "fedi")
 (autoload 'fedi--find-property-range "fedi")
@@ -49,9 +51,7 @@
 
 (defface fedi-post-docs-face
   `((t :inherit font-lock-comment-face))
-  "Face used for documentation in post compose buffer.
-If `mastodon-tl--enable-proportional-fonts' is changed,
-mastodon.el needs to be re-loaded for this to be correctly set.")
+  "Face used for documentation in post compose buffer.")
 
 (defface fedi-post-success-face
   `((t :inherit success))
@@ -60,7 +60,7 @@ mastodon.el needs to be re-loaded for this to be correctly 
set.")
 (defgroup fedi-post nil
   "Posting options for fedi.el."
   :prefix "fedi-post-"
-  :group 'mastodon)
+  :group 'fedi)
 
 (defcustom fedi-post--enable-completion t
   "Whether to enable completion of mentions and hashtags.
@@ -70,9 +70,8 @@ Used for completion in post compose buffer."
 (defcustom fedi-post--use-company-for-completion nil
   "Whether to enable company for completion.
 When non-nil, `company-mode' is enabled in the post compose
-buffer, and mastodon completion backends are added to
+buffer, and fedi or your package's completion backends are added to
 `company-capf'.
-
 You need to install company yourself to use this."
   :type 'boolean)
 
@@ -161,7 +160,7 @@ CANCEL means the post was not sent, so we save the post 
text as a draft."
     (fedi-post--restore-previous-window-config prev-window-config)))
 
 (defun fedi-post-cancel ()
-  "Kill new-post buffer/window. Does not POST content to Mastodon.
+  "Kill new-post buffer/window. Does not POST content.
 If post is not empty, prompt to save text as a draft."
   (interactive)
   (if (fedi-post--empty-p)
@@ -270,9 +269,9 @@ and a status."
 Return its two letter ISO 639 1 code."
   (interactive)
   (let* ((choice (completing-read "Language for this post: "
-                                  mastodon-iso-639-1)))
+                                  fedi-iso-639-1)))
     (setq fedi-post-language
-          (alist-get choice mastodon-iso-639-1 nil nil 'equal))
+          (alist-get choice fedi-iso-639-1 nil nil 'equal))
     (message "Language set to %s" choice)
     (fedi-post--update-status-fields)))
 
@@ -421,9 +420,9 @@ descriptions."
       'post-header t))))
 
 (defun fedi-post--count-post-chars (post-string)
-  "Count the characters in POST-STRING.
-URLs always = 23, and domain names of handles are not counted.
-This is how mastodon does it."
+  "Count the characters in POST-STRING."
+  ;; URLs always = 23, and domain names of handles are not counted.
+  ;; This is how mastodon does it."
   (with-temp-buffer
     (switch-to-buffer (current-buffer))
     (insert post-string)
@@ -501,7 +500,7 @@ Added to `after-change-functions'."
                                   'success
                                   (cdr header-region))
       (fedi-post--propertize-item fedi-post-handle-regex
-                                  'mastodon-display-name-face
+                                  'warning
                                   (cdr header-region))
       (fedi-post--propertize-item fedi-post-url-regex
                                   'link
@@ -537,7 +536,7 @@ Added to `after-change-functions'."
 ;;; COMPOSE BUFFER FUNCTION
 
 (defun fedi-post--compose-buffer
-    (&optional edit major minor prefix capf-funs &rest fields-alist)
+    (&optional edit major minor prefix type capf-funs &rest fields-alist)
   "Create a new buffer to capture text for a new post.
 EDIT means we are editing an existing post, not composing a new one.
 MAJOR is the major mode to enable.
@@ -546,7 +545,9 @@ PREFIX is a string corresponding to the prefix of the 
library
 that contains the compose buffer's functions. It is only required
 if this differs from the minor mode.
 CAPF-FUNS is a list of functions to enable."
-  (let* ((buffer-name (if edit "*edit post*" "*new post*"))
+  (let* ((buffer-name (if edit
+                          (format "*edit %s*" type)
+                        (format "*new %s*" type)))
          (buffer-exists (get-buffer buffer-name))
          (buffer (or buffer-exists (get-buffer-create buffer-name)))
          (inhibit-read-only t)
@@ -607,13 +608,13 @@ font locking to not ruin our docs header."
                                                        (point-min)))))
       (font-lock-fontify-region end-of-docs (point-max)))))
 
-;; flyspell ignore masto post regexes:
+;; flyspell ignore our post regexes:
 (defvar flyspell-generic-check-word-predicate)
 
 (defun fedi-post-mode-flyspell-verify ()
   "A predicate function for `flyspell'.
 Only text that is not one of these faces will be spell-checked."
-  (let ((faces '(mastodon-display-name-face
+  (let ((faces '(warning
                  fedi-post-docs-face font-lock-comment-face
                  success link)))
     (unless (eql (point) (point-min))

Reply via email to