My current script copies text like this with a shortcut:
:WiltedFlower: aetheryxflower ─ 4
:Alcohol: alcohol ─ 3,709
:Ant: ant ─ 11,924
:Apple: apple ─ 15
:ArmpitHair: armpithair ─ 2
and pastes it modified into a single line
Pls trade 4 aetheryxflower 3 alcohol 11 ant 15 apple 2 armpithair <#id>
As you can see there are already two little problems, the first one is that it copies only the number/s before a comma if one existed instead of ignoring it. The second is that I always need to also copy before hitting the hotkey and start re/start the script, I've thought of modifying the script so that it uses the already selected text instead of the copied one so that I can bind it with a single hotkey.
That is my current script, it would be cool if anyone can also tell me what they used and why exactly, so that I also get better with ahk
!q::
list =
While pos := RegExMatch(Clipboard, "(\w*) ─ (\d*)", m, pos ? pos + StrLen(m) : 1)
list .= m2 " " m1 " "
Clipboard := "", Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
If the pattern of your copied text dont change, you can use something like this:
#Persistent
OnClipboardChange:
list =
a := StrSplit(StrReplace(Clipboard, "`r"), "`n")
Loop,% a.Count() {
b := StrSplit( a[A_Index], ": " )
c := StrSplit( b[2], " - " )
list .= Trim( c[2] ) " " Trim( c[1] ) " "
}
Clipboard := "Pls trade " list " <#951737931159187457>"]
ToolTip % Clipboard ; just for debug
return
With your example text, the output will be:
Pls trade aetheryxflower ─ 4 alcohol ─ 3,709 ant ─ 11,924 apple ─ 15 armpithair ─ 2 <#951737931159187457>
And this will run EVERY TIME your clipboard changes, to avoid this, you can add at the top of the script #IfWinActive, WinTitle or #IfWinExist, WinTitle depending of your need.
The answer given would solve the problem, assuming that it never changes pattern as Diesson mentions.
I did the explanation of the code you provided with comments in the code below:
!q::
list = ; initalize a blank variable
; regexMatch(Haystack, regexNeedle, OutputVar, startPos)
; just for frame of reference in explanation of regexMatch
While ; loop while 'pos' <> 0
pos := RegExMatch(Clipboard ; Haystack is the string to be searched,
in this case the Clipboard
, "(\w*) ─ (\d*)" ; regex needle in this case "capture word characters
(a-z OR A-Z OR 0-9 OR _) any number of times, space dash space
then capture any number of digits (0-9)"
, m ; output var array base name, ie first capture will be in m1
second m2 and so on.
, pos ? pos + StrLen(m) : 1) ; starting position for search
"? :"used in this way is called a ternary operator, what is saying
is "if pos<>0 then length of string+pos is start position, otherwise
start at 1". Based on the docs, this shouldn't actually work well
since 'm' in this case should be left blank
list .= m2 " " m1 " " ; append the results to the 'list' variable
followed with a space
Clipboard := "" ; clear the clipboard.
Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0 ; wait zero seconds for the clipboard to change
If ErrorLevel ; if waiting zero seconds for the clipboard to change
doesn't work, give error msg to user.
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
Frankly this code is what I would call quick and dirty, and seems unlikely to work well all the time.
I am using Emacs 24.3.1 on Ubuntu 14.04, slime-20160402.549, GNU CLISP 2.4. Whenever i use read() or read-line() function in slime-repl, it will freeze after one or two input characters (e.g. "wa"),
; SLIME 2016-04-02
CL-USER> (read)
wa
Trying C-g it shows the error below:
Debugger entered--Lisp error: (quit)
accept-process-output(nil 0.01)
#[0 "\306\307!\306\310!\211\302L\266\211\211\300L\266\311\312J\301#\313\314\315\316\317D\316\nD\316\fD\320\257E\257!\266\321\322\323 \322\262\322\262\324!\325=\204J
slime-eval((swank:simple-completions "wa" (quote "COMMON-LISP-USER")))
slime-simple-completions("wa")
ac-source-slime-simple-candidates()
ac-candidates-1(((init . ac-slime-init) (candidates . ac-source-slime-simple-candidates) (candidate-face . ac-slime-menu-face) (selection-face . ac-slime-selection-face) (prefix . slime-symbol-start-pos) (symbol . "l") (document . ac-slime-documentation) (match . ac-source-slime-case-correcting-completions)))
ac-candidates()
ac-update(t)
ac-show-menu()
apply(ac-show-menu nil)
...
This problem does not happen in clisp REPL on command line.
Any helps?
I'm working in emacs with LISP and I've come across an error that I'm not sure how to get around. I'll put up the output, what I understand from it and what I'm missing.
Error:
junk in string "(-5 -4 -3 -2 -1 0 1 2 3 4 5 6)"
[Condition of type SB-INT:SIMPLE-PARSE-ERROR]
Backtrace:
0: (PARSE-INTEGER "(-5 -4 -3 -2 -1 0 1 2 3 4 5 6)" :START 0 :END NIL :RADIX 10 :JUNK-ALLOWED NIL)
1: ((:METHOD CLSQL-SYS:READ-SQL-VALUE :AROUND (T T T T)) "(-5 -4 -3 -2 -1 0 1 2 3 4 5 6)" INTEGER #<CLSQL-SQLITE3:SQLITE3-DATABASE C:/Users/sas31/idyom/db/database.sqlite OPEN {1007D61933}> :SQLITE3) [fa..
2: ((:METHOD CLSQL-SYS::UPDATE-SLOT-FROM-DB-VALUE (CLSQL-SYS:STANDARD-DB-OBJECT T T)) #<unavailable argument> #<unavailable argument> #<unavailable argument>) [fast-method]
3: (CLSQL-SYS::BUILD-OBJECTS (#<CLSQL-SYS:SELECT-LIST {100592E993}>) #<unavailable argument> #<CLSQL-SQLITE3:SQLITE3-DATABASE C:/Users/sas31/idyom/db/database.sqlite OPEN {1007D61933}> #<unavailable argu..
4: (CLSQL-SYS::FIND-ALL (IDYOM-DB:MTP-EVENT) :RESULT-TYPES :AUTO :REFRESH NIL :INSTANCES NIL :WHERE #<CLSQL-SYS:SQL-RELATIONAL-EXP (MTP_EVENT.COMPOSITION_ID = 0 AND MTP_EVENT.DATASET_ID = 26)> :FLATP T :..
5: (CLSQL-SYS::FIND-ALL (IDYOM-DB:MTP-EVENT) :RESULT-TYPES :AUTO :REFRESH NIL :INSTANCES NIL :WHERE #<CLSQL-SYS:SQL-RELATIONAL-EXP (MTP_EVENT.COMPOSITION_ID = 0 AND MTP_EVENT.DATASET_ID = 26)> :FLATP T :..
6: (CLSQL-SYS:SELECT IDYOM-DB:MTP-EVENT :WHERE #<CLSQL-SYS:SQL-RELATIONAL-EXP (MTP_EVENT.COMPOSITION_ID = 0 AND MTP_EVENT.DATASET_ID = 26)> :FLATP T :RESULT-TYPES NIL :DATABASE #<CLSQL-SQLITE3:SQLITE3-DA..
7: (CLSQL-SYS::FAULT-JOIN-SLOT #<CLSQL-SYS::STANDARD-DB-CLASS IDYOM-DB:MTP-COMPOSITION> #<IDYOM-DB:MTP-COMPOSITION {10047AAA73}> #<CLSQL-SYS::VIEW-CLASS-EFFECTIVE-SLOT-DEFINITION IDYOM-DB::EVENTS>)
8: ((:METHOD SB-MOP:SLOT-VALUE-USING-CLASS (CLSQL-SYS::STANDARD-DB-CLASS T T)) #<unavailable argument> #<unavailable argument> #<unavailable argument>) [fast-method]
9: (IDYOM-DB::GET-EVENT-SEQUENCE 26 0)
10: (IDYOM-DB:COUNT-EVENTS 26 0)
11: (MIDI2DB::FIX-BIOI-DUR-DELTAST 26)
12: (SB-INT:SIMPLE-EVAL-IN-LEXENV (MIDI2DB::FIX-BIOI-DUR-DELTAST 26) #<NULL-LEXENV>)
13: (EVAL (MIDI2DB::FIX-BIOI-DUR-DELTAST 26))
So, I would like to change :junk-allowed nil to t in parse-integer, but I don't know how to do that because I'm not where when or why it's called. The function get-event-sequence (written for this particular programme) calls get-composition, which reads as follows:
(defun get-composition (dataset-id composition-id)
"Returns the composition whose dataset-id is <dataset-id> and whose
composition-id is <composition-id>."
(car (clsql:select
'mtp-composition
:flatp t
:where [and [= [slot-value 'mtp-composition 'dataset-id] dataset-id]
[= [slot-value 'mtp-composition 'composition-id] composition-id]])))
I don't know where this parse-integer is being called from this function or how to change the value of that keyword. Also, the string of numbers are coded key signatures and represent all the key signatures in this particular data set, but why is that important when this function only seems to deal with dataset-id and composition-id? Thanks for your help!
Looking at the backtrace, we can see that parse-integer is called by a method on the generic function clsql-sys:read-sql-value.
It is not clear, without checking the code, if that :junk-allowed nil is just the backtrace showing you default values or if it's actively called that way from the method.
However, getting that set to a true value would not really help you, since the return value would be nil (because "(" is not a number or a white-space). This means that there's a deeper problem with your database, possibly due to an implicit schema violation (you've said "I want to store numbers", then stored a list of numbers and the ORM did something it cannot recover from).
* (parse-integer " 2 " :junk-allowed t)
2
2
* (parse-integer "(2 " :junk-allowed t)
NIL
0
I'm running the teapot example from cl-opengl package. The only changes I've made are loading the required packages. It works fine when executed from unix shell (sbcl --load "3.cl"), but when I try to compile and load it through SLIME (C-c C-k) i get the error about package GLUT not found.
Curiously, the compiler chokes on the (defclass glut-teapot-window (glut:window).
What gives???
Here's a screenshot of what happens
Here's the code for 3.cl.
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
;;; glut-teapot.lisp --- Simple usage of glut:solid-teapot.
(ql:quickload :cl-opengl)
(ql:quickload :cl-glu)
(ql:quickload :cl-glut)
;(setf *communication-style* :fd-handler)
(defclass glut-teapot-window (glut:window)
()
(:default-initargs :width 250 :height 250 :title "glut-teapot.lisp"
:mode '(:single :rgb :depth)))
(defmethod glut:display-window :before ((w glut-teapot-window))
(gl:clear-color 0 0 0 0)
(gl:cull-face :back)
(gl:depth-func :less)
(gl:disable :dither)
(gl:shade-model :smooth)
(gl:light-model :light-model-local-viewer 1)
(gl:color-material :front :ambient-and-diffuse)
(gl:enable :light0 :light1 :lighting :cull-face :depth-test))
(defmethod glut:display ((window glut-teapot-window))
(gl:load-identity)
(gl:translate 0 0 -5)
(gl:rotate 30 1 1 0)
(gl:light :light0 :position '(100 1000 1 0))
(gl:light :light0 :diffuse '(1.2 0.4 0.6 0))
(gl:light :light1 :position '(-100 1000 1 0))
(gl:clear :color-buffer :depth-buffer)
(gl:color 1 10 1)
(gl:front-face :cw)
(glut:solid-teapot 1.3)
;(glut:solid-torus 0.5 1.0 50 50)
;(glu:cylinder (glu:new-quadric) 0.5 0.5 0.5 20 20)
(gl:front-face :ccw)
(gl:flush))
(defmethod glut:reshape ((window glut-teapot-window) width height)
(gl:viewport 0 0 width height)
(gl:matrix-mode :projection)
(gl:load-identity)
(glu:perspective 50 (/ width height) 0.5 20)
(gl:matrix-mode :modelview)
(gl:load-identity))
(defmethod glut:keyboard ((window glut-teapot-window) key x y)
(declare (ignore x y))
(when (eql key #\Esc)
(glut:destroy-current-window)))
(defun glut-teapot ()
(glut:display-window (make-instance 'glut-teapot-window)))
(glut-teapot)
If you load the file, the Lisp system reads the file expression by expression and executes them after reading each single expression.
If you compile the file in a fresh Lisp, then it reads the expressions and compiles them. But it does not execute them. Thus it sees the quickload command, compiles it, but does not execute it. This OpenGL code is not loaded and the packages are not known to the compiler. But that makes sense: a compile usually should compile the file, not execute it. Lisp would execute the expressions then when you load the compiled fasl file.
There are two simple ways around it:
put the quickload operation in a separate file and compile/execute it before compiling the next file.
enclose the load operations in an EVAL-WHEN statement. (eval-when (:execute :load-toplevel :compile-toplevel) ... your code here ...).
The :compile-toplevel symbol means, that the code will be executed when the compiler sees it as a top-level form. Which it otherwise would not do. Thus you can have code in a file to compile which creates side effects - here loading other code.
I use 'note and timestamp' on 'DONE' state change. In my custom agenda command I define that I want to see the state change log. But it appears that I still see the original repeating TODO. I would like to only see the state change log.
I have tried two different configurations. The first does not provide me the state change, the second provides the state change log but also repeats.
Any ideas how to trim the agenda to show only the state change log?
TODO entry in 'company.org':
* Agenda
** TODO Acronis : Backup Check :DAILY:
SCHEDULED:
:LOGBOOK:
- State "DONE" from "TODO" [2012-10-25 Thu 10:31] \\
Reverted 'proud' back to central storage. Asked about RAM upgrade. Scheduled for Monday.
:END:
:PROPERTIES:
:LAST_REPEAT: [2012-10-25 Thu 10:31]
:END:
TODO state change sequence:
;; '!' (for a timestamp) or '#' (for a note with timestamp)
(setq org-todo-keywords
'((sequence "TODO(t)" "PROJ(p)" "APPT(a)" "|" "DONE(d#)")))
Custom agenda command:
("c" agenda "Company 60"
(
(org-agenda-files '("~/shoebox/read/org/company.org"))
(org-agenda-ndays 60)
(org-deadline-warning-days 7)
(org-agenda-sorting-strategy '(time-up todo-state-up priority-down))
(org-agenda-time-grid nil)
(org-agenda-repeating-timestamp-show-all nil)
(org-agenda-show-log t)
(org-agenda-log-mode-items '(state))
(org-agenda-show-all-dates nil) ;; only show days with something
(org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp ":DAILY:"))
))
Produces:
60 days-agenda (W43-W51):
Thursday 25 October 2012
company: 10:00...... Scheduled: TODO Acronis : Backup Check :DAILY:
Where as:
("c" "Company 60"
((agenda ""))
(
(org-agenda-files '("~/shoebox/read/org/company.org"))
(org-agenda-ndays 60)
(org-deadline-warning-days 7)
(org-agenda-sorting-strategy '(time-up todo-state-up priority-down))
(org-agenda-time-grid nil)
(org-agenda-repeating-timestamp-show-all nil)
(org-agenda-show-log t)
(org-agenda-log-mode-items '(state))
(org-agenda-show-all-dates nil) ;; only show days with something
(org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp ":DAILY:"))
))
Produces:
60 days-agenda (W43-W51):
Thursday 25 October 2012
Company: 10:00...... Scheduled: TODO Acronis : Backup Check :DAILY:
Company: 10:31...... State: (DONE) TODO Acronis : Backup Check - Reverted 'proud' back to central storage. Asked about RAM upgrade. Scheduled for Monday. :DAILY: