sync for reymacs development

This commit is contained in:
Jacob Hrbek 2020-09-01 20:23:05 +02:00
parent a87baf1670
commit 349c7171fb
9 changed files with 81 additions and 54 deletions

View File

@ -3,17 +3,20 @@
;; Created by Jacob Hrbek identified with an e-mail <kreyren@rixotstudio.cz> and GPG signature <0x765AED304211C28410D5C478FCBA0482B0AB9F10> under all rights reserved in 26/08/2020 11:11:38 CEST
;; WARNING: NOT IMPLEMENTED!
(message "NOT IMPLEMENTED!")
(kill-emacs 36)
;(message "NOT IMPLEMENTED!")
;(kill-emacs 36)
;; Source variables
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-debug.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-log-file.el")
(require 'cl-lib)
;; Source wrappers
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/wrappers/zn-defun.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/wrappers/zn-defvar.el")
;; Source variables
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-debug.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-log-file.el")
;;(setq emacs-log-file "/home/kreyren/emacs.log")
;; Source functions
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/die.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/ewarn.el")
@ -22,4 +25,4 @@
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/edebug.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/eerror.el")
(die "true" "dasdgag")
(die "true")

View File

@ -34,6 +34,7 @@
(defvar die-format-string-buunexpectedg-debug "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using unexpected trap")
(defvar die-format-string-unexpected-debug-log "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using unexpected trap")
;; FIXME-TEST: Make sure that function 'die' works after changes
(zn-defun die (exitcode &optional message)
"Reimplementation of a non-standard function provided by the Zernit project (https://github.com/RXT0112/Zernit/blob/master/src/RXT0112-1/downstream-classes/zeres-0/bash/output/die.sh) into an emacs lisp that allow assertion of elisp runner with specified exit code and message with logging and debugging.
@ -63,8 +64,7 @@ Requires following variables:
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-success message))
(append-to-file (format die-format-string-success-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -73,10 +73,11 @@ Requires following variables:
(append-to-file (format die-format-string-success-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
(princ (format die-format-string-success message "Logically determined that processed finished successfully"))
(append-to-file (format die-format-string-success-log message "Logically determined that processed finished successfully") nil emacs-log-file) )
)
)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-success "Logically determined that processed finished successfully"))
(append-to-file (format die-format-string-success-log "Logically determined that processed finished successfully") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
@ -98,8 +99,7 @@ Requires following variables:
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((> (length message) 0)
(princ (format die-format-string-failure message))
(append-to-file (format die-format-string-failure-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -109,7 +109,7 @@ Requires following variables:
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-failure message "Logically determined that process failed"))
(append-to-file (format die-format-string-failure-log message "Logically determined that processed failed") nil emacs-log-file) )
(t
@ -134,7 +134,7 @@ Requires following variables:
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((> (length message) 0)
(princ (format die-format-string-security message))
(append-to-file (format die-format-string-security-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -144,7 +144,7 @@ Requires following variables:
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-security message "Runtime tripped security trap, exitting for safety"))
(append-to-file (format die-format-string-security-log message "Runtime tripped security trap, exitting for safety") nil emacs-log-file) )
(t
@ -160,7 +160,7 @@ Requires following variables:
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((> (length message) 0)
(princ (format die-format-string-fixme message))
(append-to-file (format die-format-string-fixme-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -170,7 +170,7 @@ Requires following variables:
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-fixme message "Runtime tripped fixme trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-fixme-log message "Runtime tripped fixme trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t
@ -186,7 +186,7 @@ Requires following variables:
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((> (length message) 0)
(princ (format die-format-string-bug message))
(append-to-file (format die-format-string-bug-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -196,7 +196,7 @@ Requires following variables:
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug message "Runtime tripped bug trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-bug-log message "Runtime tripped bug trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t
@ -212,7 +212,7 @@ Requires following variables:
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (lenght message) 0)
((> (length message) 0)
(princ (format die-format-string-unexpected message))
(append-to-file (format die-format-string-unexpected-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
@ -222,7 +222,7 @@ Requires following variables:
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((= (length message) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-unexpected message "Runtime tripped unexpected trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-unexpected-log message "Runtime tripped unexpected trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t

View File

@ -9,14 +9,14 @@
"Non-standard function used to output in the buffer with logging support to annoy the end-user with fixme messages for code quality issues that might influence the runtime"
(cond
((= (lenght message ) 0)
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message))
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)))
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file) )
((> (lenght message) 0)
(princ (format edebug-format-string message)
(append-to-file (format edebug-format-string message) nil emacs-log-file)) )
(t
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message))
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)))
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file)
)
)

View File

@ -8,14 +8,14 @@
"Non-standard function used to output in the buffer with logging support to inform the end-user about non-fatal errors"
(cond
((= (lenght message ) 0)
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message))
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)))
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file) )
((> (lenght message) 0)
(princ (format eerror-format-string message)
(append-to-file (format eerror-format-string message) nil emacs-log-file)) )
(princ (format eerror-format-string message))
(append-to-file (format eerror-format-string message) nil emacs-log-file))
(t
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message))
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)))
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file)
)
)

View File

@ -9,14 +9,14 @@
"Non-standard function used to output in the buffer with logging support to annoy the end-user with fixme messages for code quality issues that might influence the runtime"
(cond
((= (lenght message ) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message))
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file) )
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file)) )
((> (lenght message) 0)
(princ (format efixme-format-string message)
(append-to-file (format efixme-format-string message) nil emacs-log-file)) )
(t
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message))
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)))
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file)
)
)

View File

@ -8,14 +8,14 @@
"Non-standard function used to output in the buffer with logging support to inform the end-user about runtime events"
(cond
((= (lenght message ) 0)
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message))
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)))
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file) )
((> (lenght message) 0)
(princ (format einfo-format-string message)
(append-to-file (format einfo-format-string message) nil emacs-log-file)) )
(t
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message))
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)))
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file)
)
)

View File

@ -8,15 +8,14 @@
"Non-standard function used to output in the buffer with logging support to warn the end-user about potential issues"
(cond
((= (lenght message ) 0)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message))
(append-to-file (format die-format-string-bug (format "Function '%1$s' was used without specified message '%2$s'" function-name message)) nil emacs-log-file) )
((> (lenght message) 0)
(princ (format ewarn-format-string message)
(append-to-file (format ewarn-format-string message) nil emacs-log-file)) )
(princ (format ewarn-format-string message))
(append-to-file (format ewarn-format-string message) nil emacs-log-file) )
(t
(princ (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message))
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file)
)
(append-to-file (format die-format-string-unexpected (format "Function '%1$s' with argument 'message' storing value '%2$s' triggered an unexpected trap which usually indicates insufficient programming logic" function-name message)) nil emacs-log-file))) )
)
)

View File

@ -2,33 +2,58 @@
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Created by Jacob Hrbek identified with an electronic mail <kreyren@rixotstudio.cz> and GPG signature <0x765AED304211C28410D5C478FCBA0482B0AB9F10> under all rights reserved in 26/08/2020 11:11:38 CEST
;; RELEVANT: XDG specification used for non-standard file hiearchy on unix https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
;; FIXME-QA: Wrap defvar simmilar to defun so that we can use 'var-name'
(zn-defvar emacs-log-file
(cl-case system-type
((gnu gnu/linux gnu/kfreebsd darwin cygwin aix berkeley-unix hpux irix usg-unix-v)
;;; Find the file to write logs into
;;; On Linux this should be writing in '/var/log/emacs/emacs-version/emacs.log' assuming it being present else '$HOME/.local/share/emacs/emacs-version/emacs.log'
(cond ;; Check if we can use XDG_DATA_HOME variable
((= (lenght (getenv "XDG_DATA_HOME")) 0)
;; Check if we can write in /var/log/emacs/emacs-version/emacs.log
((file-writable-p (format "%1$s%2$s%3$s" "/var/log/emacs/" emacs-build-number "/emacs.log"))
(concat (format "%1$s%2$s%3$s" "/var/log/emacs/" emacs-build-number "/emacs.log")) )
((> (length (getenv "XDG_DATA_HOME")) 0)
;; FIXME-QA: Make sure that XDG_DATA_HOME is present
(cond
((file-writable-p (concat (getenv "XDG_DATA_HOME") (format "%1$s%2$s" "/emacs/" emacs-build-number "/emacs.log")))
(concat (getenv "XDG_DATA_HOME") (format "%1$s%2$s" "/emacs/" emacs-build-number "/emacs.log")) )
(t
(princ "FATAL: %1$s\n" (format "Path '%1$s' is not writable and thus can not be used for a logging file" (concat (getenv "XDG_DATA_HOME") (format "%1$s%2$s" "/emacs/" emacs-build-number "/emacs.log")))) )
)
)
((= (length (getenv "XDG_DATA_HOME")) 0)
;; FIXME-QA: Make sure that HOME is present
;; FIXME-QA: Make sure that HOME is writable
(string (getenv "HOME")"emacs.log") )
((> (lenght (getenv "XDG_DATA_HOME")) 0)
;; FIXME-QA: Make sure that XDG_DATA_HOME is present
;; FIXME-QA: Make sure that XDG_DATA_HOME is writable
(string (getenv "XDG_DATA_HOME")"emacs/emacs.log") )
(cond
((> (length (getenv "HOME")) 0)
;; FIXME-QA: Output message inside zn-defvar's argument without getting 'Invalid function' fatal err
;;(princ "WARN: %1$s\n" (format "Variable 'XDG_DATA_HOME' is storing a blank value '%1$s' and so it can't be used for logging, using '%2$s'" (getenv "XDG_DATA_HOME") (concat (getenv "HOME")"/emacs.log") ))
(concat (getenv "HOME")"/emacs.log") )
(t
(princ "WARN: %1$s\n" (format "Unable to define variable '%1s$' as variable 'HOME' is storing a blank value '%2$s', thus we are unable to generate a log file" var-name (getenv HOME)))
(concat nil))
)
)
(t
(princ (format die-format-string-bug (format "Unexpected happend while defining variable '%1$s' checking for the lenght of 'XDG_DATA_HOME' variable that stores value '%2$s'" var-name (getenv XDG_DATA_HOME))))
(princ (format "BUG: %1$s\n" (format "Unexpected happend while defining variable '%1$s' checking for the lenght of 'XDG_DATA_HOME' variable that stores value '%2$s'" var-name (getenv XDG_DATA_HOME))))
(append-to-file (format die-format-string-bug (format die-format-string-bug (format "Unexpected happend while defining variable '%1$s' checking for the lenght of 'XDG_DATA_HOME' variable that stores value '%2$s'" var-name (getenv "XDG_DATA_HOME")))) nil emacs-log-file)
(kill-emacs 250) )
)
)
((windows-nt ms-dos)
;; FIXME: Provide a default INITVALUE that contains a sane path to be used for a logging file
(princ (format die-format-string-fixme (format "Platform '%1$s' is not implemented in a non-standard variable '%2$s' to provide INITVALUE" system-type var-name)))
(princ (format "FIXME: %1$s\n" (format "Platform '%1$s' is not implemented in a non-standard variable '%2$s' to provide INITVALUE" system-type var-name)))
(kill-emacs 28) )
(otherwise
(princ (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in defining variable '%2$s'" system-type var-name)))
(append-to-file (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)) nil emacs-log-file )
(t
(princ (format "UNEXPECTED: %1$s\n" (format "Platform '%1$s' is not implemented in defining variable '%2$s'" system-type var-name)))
(append-to-file (format "UNEXPECTED: %1$s\n" (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
"Non-standard variable used by logging backend of the zernit project to generate a log file using programming logic, This must be set otherwise the function is going to fail."
"Non-standard variable used by logging backend of the zernit project to generate a log file using programming logic implemented by zernit project
On linux this expects environmental variables:
- XDG_DATA_HOME: Used for finding a location used for a log file, if not set it uses HOME/emacs.log
- HOME: Used for finding a location for a log file in case XDG_DATA_HOME is not set, sets itself to 'nil' if HOME is not writable"
)