elisp: init

This commit is contained in:
Jacob Hrbek 2020-08-30 23:18:22 +02:00
parent 488f2b190f
commit a87baf1670
15 changed files with 526 additions and 2 deletions

View File

@ -8,6 +8,11 @@ all:
@ printf '%s\n' "Unknown option '$1' parsed in target all"
@ exit 2
## UNLEASH RUNTIME ##
unleash-elisp:
@ src/RXT0112-1/downstream-classes/zeres-0/elisp/UNLEASH.el
## BUILD ##
# All build targets are expected in 'build/build-LANG' where 'LANG' is the unique identifier of the language used
# FIXME: Replace 'exit 1' with helpful messages
@ -117,7 +122,7 @@ check-vlang:
# FIXME: Run all benches if this is executed
bench: bench-rustlang
# FIXME: Run vendor and
# FIXME: Run vendor and
bench-rustlang:
@ cargo bench
@ -129,4 +134,4 @@ clean: clean-vendor clean-benches
clean-vendor:
@ # FIXME: Output helpful message if directory doesn't exists
@ [ -d vendor ] && { rm -rf vendor || exit 1 ;} || exit 0
@ [ -d vendor ] && { rm -rf vendor || exit 1 ;} || exit 0

12
emacs.log Normal file
View File

@ -0,0 +1,12 @@
SUCCESS: test!
SUCCESS: test!
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil

View File

@ -0,0 +1,8 @@
# Emacs-lisp downstream class
Downstream class used by zernit the over-engineered package manager to process it's downstream items using elisp runner.
### FAQ
Q: Why
A: Because we can dammit! Also krey's emacs needs a package manager..

View File

@ -0,0 +1,25 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; 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)
;; 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")
;; 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 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")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/einfo.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/efixme.el")
(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")

View File

@ -0,0 +1,242 @@
#!/bin/sh
":"; 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
;; Formatting string declaration
;;; Success
(defvar die-format-string-success "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using success trap")
(defvar die-format-string-success-log "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using success trap")
(defvar die-format-string-success-debug "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using success trap")
(defvar die-format-string-success-debug-log "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using success trap")
;;; Failure
(defvar die-format-string-failure "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using failure trap")
(defvar die-format-string-failure-log "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using failure trap")
(defvar die-format-string-failure-debug "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using failure trap")
(defvar die-format-string-failure-debug-log "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using failure trap")
;;; Security
(defvar die-format-string-security "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using security trap")
(defvar die-format-string-security-log "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using security trap")
(defvar die-format-string-security-debug "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using security trap")
(defvar die-format-string-security-debug-log "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using security trap")
;;; Fixme
(defvar die-format-string-fixme "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using fixme trap")
(defvar die-format-string-fixme-log "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using fixme trap")
(defvar die-format-string-fixme-debug "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using fixme trap")
(defvar die-format-string-fixme-debug-log "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using fixme trap")
;;; Bug
(defvar die-format-string-bug "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using bug trap")
(defvar die-format-string-bug-log "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using bug trap")
(defvar die-format-string-bug-debug "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using bug trap")
(defvar die-format-string-bug-debug-log "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using bug trap")
;;; Unexpected
(defvar die-format-string-unexpected "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using unexpected trap")
(defvar die-format-string-unexpected-log "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using unexpected trap")
(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")
(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.
Due to the cross-platform compatibility the function is using strings for the exit codes instead of numerical values.
- true - Returns 0 on linux and 1 on windows to exit successfully
- false - Returns 1 on linux and 0 on windows for general failure
- security - Returns 28, used to fail safely in case security threat is detected
- fixme - Returns 36, used for unimplemented features
- bug - Returns 250, used to capture bugs in the wild
- unexpected - Returns 255, used for unexpected behavior
Messages are optional, if no message is provided the function will use a hardcoded message which should be avoided when the message might me inaccurate to the failure point to avoid user confusion.
Formatting strings of the messages are variables designed to be customized on demand using variables:
- '<function-name>-format-string-<exitcode>' for regular messages
- '<function-name>-format-string-<exitcode>-debug' for regular messages with debugging enabled
- '<function-name>-format-string-<exitcode>-log' for logging output in path defined in non-standard variable `emacs-log-file'
- '<function-name>-format-string-<exitcode>-log' for logging output in path defined in non-standard variable `emacs-log-file' with debugging enabled
Requires following variables:
- `emacs-log-file' - Non-standard variable used to output logging in a path of file
- `emacs-debug' - Non-standard variable used to set debugging level"
(pcase exitcode
("true" ;; Generic success
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-success-debug message))
(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) )
(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 )
(kill-emacs 250) )
)
(cl-case system-type
((gnu gnu/linux gnu/kfreebsd darwin cygwin aix berkeley-unix hpux irix usg-unix-v)
(kill-emacs 0) )
((windows-nt ms-dos)
(kill-emacs 1) )
(otherwise
(princ (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)))
(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 ) )
(kill-emacs 250)
)
)
("false" ;; Generic failure
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-failure-debug message))
(append-to-file (format die-format-string-failure-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-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
(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 )
(kill-emacs 250) )
)
(cl-case system-type
((gnu gnu/linux gnu/kfreebsd darwin cygwin aix berkeley-unix hpux irix usg-unix-v)
(kill-emacs 1) )
((windows-nt ms-dos)
(kill-emacs 0) )
(otherwise
(princ (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)))
(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 ) )
(kill-emacs 250)
)
)
("security" ;; Security trap
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-security-debug message))
(append-to-file (format die-format-string-security-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-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
(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 )
(kill-emacs 250) )
)
(kill-emacs 28)
)
("fixme" ;; Fixme trap
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-fixme-debug message))
(append-to-file (format die-format-string-fixme-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-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
(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 )
(kill-emacs 250) )
)
(kill-emacs 36)
)
("bug" ;; Bug trap
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-bug-debug message))
(append-to-file (format die-format-string-bug-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-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
(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 )
(kill-emacs 250) )
)
(kill-emacs 250)
)
("unexpected" ;; Unexpected trap
(cond
;; 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)
(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
((string-equal emacs-debug function-name)
(princ (format die-format-string-unexpected-debug message))
(append-to-file (format die-format-string-unexpected-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-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
(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 )
(kill-emacs 250) )
)
(kill-emacs 255)
)
("" ;; No argument provided
(princ (format die-format-string-bug (format "No argument was provided in function '%1$s' which is not implemented to handle this scenario" function-name)))
(kill-emacs 250) )
(_ ;; unimplemented argument provided
(princ (format die-format-string-bug (format "Argument '%1$s' is not implemented in function '%2$s'" exitcode function-name)))
(kill-emacs 250) )
)
)

View File

@ -0,0 +1,23 @@
#!/bin/sh
":"; 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
(defvar edebug-format-string "DEBUG: %s\n" "Non-standard variable used to define a formatting string for non-standard `efixme' function defined by the zernit project")
;; FIXME: Implement logging levels that output based on value in variable 'emacs-debug'
(zn-defun edebug (level message)
"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))
(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))
(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

@ -0,0 +1,22 @@
#!/bin/sh
":"; 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
(defvar eerror-format-string "ERROR: %s\n" "Non-standard variable used to define a formatting string for non-standard `eerror' function defined by the zernit project")
(zn-defun eerror (message)
"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))
(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)) )
(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)
)
)
)

View File

@ -0,0 +1,23 @@
#!/bin/sh
":"; 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
(defvar efixme-format-string "FIXME: %s\n" "Non-standard variable used to define a formatting string for non-standard `efixme' function defined by the zernit project")
;; FIXME: Do not output if disabled though user-configuration
(zn-defun efixme (message)
"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))
(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))
(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

@ -0,0 +1,22 @@
#!/bin/sh
":"; 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
(defvar einfo-format-string "INFO: %s\n" "Non-standard variable used to define a formatting string for non-standard `einfo' function defined by the zernit project")
(zn-defun einfo (message)
"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))
(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))
(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

@ -0,0 +1,22 @@
#!/bin/sh
":"; 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
(defvar ewarn-format-string "WARN: %s\n" "Non-standard variable used to define a formatting string for non-standard `ewarn' function defined by the zernit project")
(zn-defun ewarn (message)
"Non-standard function used to output in the buffer with logging support to warn the end-user about potential issues"
(cond
((= (lenght message ) 0)
(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)) )
(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)
)
)
)

View File

@ -0,0 +1,47 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;;; TEST: Make sure that function-name stores valid name
;; FIXME: Implement cl-case instead of cond for better readability (https://www.gnu.org/software/emacs/manual/html_node/cl/Conditionals.html)
(zn-defun test-rm-defun-function-name-validity (message)
(cond
((string-equal function-name "test-rm-defun-function-name-validity")
(message "Test for checking function-name validity passed, variable 'function-name' stores '%s' for function name 'test-rm-defun-function-name-validity'", function-name)
(cond
((string-equal system-type "gnu/linux")
(kill-emacs 1))
((string-equal system-type "windows-nt")
(kill-emacs 0))
(t
(message "BUG: Function 'test-rm-defun-function-name-validity' triggered unexpected logic for system type '%s' for killing emacs as a result of failed test" system-type)
(kill-emacs 250))
)
;; DNM
((if (string= function-name "test-rm-defun-function-name-validity") '() t)
(message "Test for checking function-name validity failed, variable function-name stores value '%s' when expected is 'test-rm-defun-function-name-validity'" function-name)
(cond
((string-equal system-type "gnu/linux")
(kill-emacs 1))
((string-equal system-type "windows-nt")
(kill-emacs 0))
(t
(message "BUG: Function 'test-rm-defun-function-name-validity' triggered unexpected logic for system type '%s' for killing emacs as a result of failed test" system-type)
(kill-emacs 250))
)
((= (length function-name) 0)
(message "Test for checking function-name validity failed, variable function-name stores value '%s'" function-name)
(cond
((string-equal system-type "gnu/linux")
(kill-emacs 1))
((string-equal system-type "windows-nt")
(kill-emacs 0))
(t
(message "BUG: Function 'test-rm-defun-function-name-validity' triggered unexpected logic for system type '%s' for killing emacs as a result of failed test" system-type)
(kill-emacs 250))
)
)
(t
(message "BUG: Function 'test-rm-defun-function-name-validity' triggered unexpected logic for checking lenght of variable 'function-name' with value %s" function-name)
(kill-emacs 250))
)
)
)

View File

@ -0,0 +1,9 @@
#!/bin/sh
":"; 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
(defvar
emacs-debug
0 ;; Disable debugging
"Non-standard variable used to output hardcodded logic in zernit"
)

View File

@ -0,0 +1,34 @@
#!/bin/sh
":"; 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
;; 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)
(cond ;; Check if we can use XDG_DATA_HOME variable
((= (lenght (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") )
(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))))
(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)))
(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 )
(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."
)

View File

@ -0,0 +1,15 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Created by Jacob Hrbek identified with email kreyren@rixotstudio.cz and gpg key 0x765AED304211C28410D5C478FCBA0482B0AB9F10 under all rights reserved in 27/08/2020 21:57:59 CEST
;;;! Wrapper for standard function 'defun'
;;;! Currently allows to reference a variable 'function-name' to use function name
(defmacro zn-defun (name args &rest body)
"Wrapper for standard function 'defun'"
;; Store the function name in function-name variable
(declare (indent 2))
`(defun ,name ,args
(let ((function-name ',name))
,@body)
)
)

View File

@ -0,0 +1,15 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Created by Jacob Hrbek identified with email kreyren@rixotstudio.cz and gpg key 0x765AED304211C28410D5C478FCBA0482B0AB9F10 under all rights reserved in 27/08/2020 21:57:59 CEST
;;;! Wrapper for standard function 'defun'
;;;! Currently allows to reference a variable 'function-name' to use function name
(defmacro zn-defvar (name args &rest body)
"Wrapper for standard function 'defvar'"
;; Store the function name in function-name variable
(declare (indent 2))
`(defvar ,name ,args
(let ((var-name ',name))
,@body)
)
)