· 5 years ago · Feb 12, 2020, 07:06 PM
1;; Added by Package.el. This must come before configurations of
2;; installed packages. Don't delete this line. If you don't want it,
3;; just comment it out by adding a semicolon to the start of the line.
4;; You may delete these explanatory comments.
5(package-initialize)
6
7(put 'upcase-region 'disabled nil)
8(put 'erase-buffer 'disabled nil)
9(custom-set-variables
10 ;; custom-set-variables was added by Custom.
11 ;; If you edit it by hand, you could mess it up, so be careful.
12 ;; Your init file should contain only one such instance.
13 ;; If there is more than one, they won't work right.
14 '(ansi-color-faces-vector
15 [default default default italic underline success warning error])
16 '(ansi-color-names-vector
17 ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"])
18 '(column-number-mode t)
19 '(custom-enabled-themes (quote (deeper-blue)))
20 '(display-time-mode t)
21 '(global-ede-mode t)
22 '(package-selected-packages (quote (undo-tree csharp-mode)))
23 '(save-place-mode t)
24 '(semantic-mode t)
25 '(show-paren-mode t)
26 '(size-indication-mode t)
27 '(window-divider-default-places t))
28(custom-set-faces
29 ;; custom-set-faces was added by Custom.
30 ;; If you edit it by hand, you could mess it up, so be careful.
31 ;; Your init file should contain only one such instance.
32 ;; If there is more than one, they won't work right.
33 '(default ((t (:family "DejaVu Sans Mono" :foundry "outline" :slant normal :weight bold :height 120 :width normal)))))
34
35;; Custom elisp functions begin here.
36
37(defun fill-to-end80(char)
38 "Fills the rest of the line up to column 80 with whatever character you insert."
39 (interactive "c80 Please Enter a Fill Character: ")
40 (end-of-line)
41 (insert " ")
42 (while ( < (current-column) 80)
43 (insert-char char)))
44(defalias 'f-t-e80 'fill-to-end80)
45
46(defun fill-to-end120(char)
47 "Fills the rest of the line up to column 120 with whatever character you insert."
48 (interactive "c120 Please Enter a Fill Character: ")
49 (end-of-line)
50 (insert " ")
51 (while ( < (current-column) 120)
52 (insert-char char)))
53(defalias 'f-t-e120 'fill-to-end120)
54
55(defun fill-to-end200(char)
56 "Fills the rest of the line up to column 200 with whatever character you insert."
57 (interactive "c200 Please Enter a Fill Character: ")
58 (end-of-line)
59 (insert " ")
60 (while ( < (current-column) 200)
61 (insert-char char)))
62(defalias 'f-t-e200 'fill-to-end200)
63
64(defun tl-mark-line(char)
65 "Marks the end of the line for task list marking."
66 (interactive "cEnter A Fill Character. Enter \"X\" If The Task Is Done, \"Y\" If The Task Is Worked On, But Not Done Or \"N\" If The Task Is New: ")
67 (end-of-line)
68 (let (repeat
69 endOfLine
70 pos1
71 pos2)
72 (setq pos2 (point))
73 (backward-char 6)
74 (setq pos1 (point))
75 (setq endOfLine (buffer-substring-no-properties pos1 pos2))
76 (if (or (string= "XXXXXX" endOfLine) (string= "YYYYYY" endOfLine) (string= "NNNNNN" endOfLine))
77 (goto-char pos1)
78 (goto-char pos2))
79 (if (or (string= "XXXXXX" endOfLine) (string= "YYYYYY" endOfLine) (string= "NNNNNN" endOfLine))
80 (kill-line))
81 (if (or (string= "XXXXXX" endOfLine) (string= "YYYYYY" endOfLine) (string= "NNNNNN" endOfLine))
82 (delete-backward-char 1))
83 (setq repeat 0)
84 (insert " ")
85 (while ( < repeat 6)
86 (insert char)
87 (setq repeat (+ 1 repeat)))
88 (tl-highlight)))
89
90(defalias 'tlml 'tl-mark-line)
91
92(defun auto-new-line()
93"This goes to the selected column, adds a new line, adds a tab, and then procedes to do the same thing on the next lines until it reaches the end of the buffer."
94 (interactive)
95 (let (col) ;; This is an Elisp "let" statement. It basically makes the variable "col" only a local variable.
96 (setq col (read-from-minibuffer "Enter the column that you would like to act as a separator: ")) ;; this sets the value of "col" to whatever the user enters.
97 (while (< (point) (- (point-max) 1)) ;; This is a while loop that will run until "point" reaches the end of the buffer.
98 (move-to-column 0)
99 (insert ?\n)
100 (move-to-column (string-to-number col)) ;; Moves to the column that the user entered.
101 (insert ?\n) ;;Inserts a new line to separate the data at this column
102 (insert ?\t) ;; Inserts a tab to help visually separate the data on the previous line.
103 (end-of-line) ;; Moves point to the end of the line for purposes of testing the if statement in the next line.
104 (if (< (point) (- (point-max) 1)) ;; Insures that the defun will only move to the next line if it actually exists.
105 (next-line))))) ;; Moves to the next line (if the "IF" function criteria was passed before.)
106
107
108(defalias 'a-n-l 'auto-new-line)
109
110
111
112(defun auto-query-copy()
113 "If you have a series of queries that you would like to copy, this works to save you from having to highlight and copy them manually."
114 (interactive)
115 (ergoemacs-select-current-block)
116 (ergoemacs-copy-line-or-region)
117 (move-to-column 0)
118 (next-line 2))
119(defalias 'a-q-c 'auto-query-copy)
120
121(defun prlRes(r1 r2)
122 "Just here for an example of a math functions in Elisp. It gives the value of two resistors in parallel."
123 (expt ( + (expt r1 -1) ( expt r2 -1)) -1))
124(defalias 'prs 'prlRes)
125
126(defun auto-in-function()
127 "Automatically creates a SQL 'IN' function from a list of items separated by a new line. You will use this quite a lot when creating queries."
128 (interactive)
129 (picture-mode)
130 (picture-mode-exit)
131 (beginning-of-buffer)
132 (while (search-forward-regexp "^" nil t)
133 (replace-match "'" nil))
134 (beginning-of-buffer)
135 (while (search-forward-regexp "[0-9A-Z]$" nil t)
136 (replace-match "\\&', " nil))
137 (beginning-of-buffer)
138 (while (search-forward-regexp "^' $" nil t)
139 (replace-match "" nil))
140 (beginning-of-buffer)
141 (while (search-forward-regexp "\n" nil t)
142 (replace-match "" nil))
143 (beginning-of-buffer)
144 (while (search-forward-regexp ", '$" nil t)
145 (replace-match ")" nil))
146 (beginning-of-buffer)
147 (while (search-forward-regexp "^" nil t)
148 (replace-match "IN(" nil))
149 (copy-region-as-kill (point-min) (point-max)))
150(defalias 'a-i-f 'auto-in-function)
151
152(defun fl-change-log()
153 "I created this to automatically copy all \"FL Types\" during functional location categorization maintenance. It will also automatically create the change log summary at the end of the functional location text file."
154 (interactive)
155 (end-of-buffer)
156 (insert "\n\n\nChanges were made to the following functional location types..\n")
157 (setq pos3 (point)) ;;Records the position here so that it can be used later when sorting lines.
158 (beginning-of-buffer)
159 (forward-paragraph) ;; This is to insure that the quotation mark copying is only done after the functional location list. As long as all of the functional locations are only separated by one new line, this will work.
160 (while (search-forward "\"" nil t) ;;Searches for the next instance of a double quotation mark. As long as qutation marks are found at this step the loop will run.
161 (setq pos (point)) ;;Sets the variable "pos" here for copying the substring.
162 (search-forward "\"" nil nil) ;;Searches for the next instance of a double quotation mark. If it does not find one, the defun exits.
163 (backward-char) ;; This moves backwards one character so that it only copies what is between quotation marks, and not the quotation marks themselves.
164 (setq pos2 (point)) ;;This records the value of point here for copying.
165 (forward-char) ;; Moves forward one character so that when the search is performed again, it finds the next quotation mark, and not the same one here.
166 (save-excursion ;; Save-excursion means that after this section of code is ran, the point will be returned here.
167 (end-of-buffer)
168 (insert "\n" (buffer-substring-no-properties pos pos2)))) ;; At the end of the buffer it inserts the substring that is in between "pos" and "pos2." This is also the end of the loop after this the loop starts over again until there are no more quotation marks to be found.
169 (goto-char pos3) ;; Returns to the "pos3" point that was saved earlier.
170 (sort-lines nil (point) (point-max)) ;;Sorts the lines between "pos3" and the end of the line. This insures that the list will be in alphabetical order.
171 (backward-paragraph) ;; This returns the point to the beginning of the paragraph after the sort.
172 (while (search-forward-regexp "\\.$" nil t) ;;This is a while loop that erases all periods at the end of a line.
173 (replace-match "" nil))
174 (whitespace-cleanup) ;;Removes whitespace.
175 (backward-paragraph) ;;Returns point to the beginning of the list.
176 (delete-duplicate-lines (point) (point-max))) ;;Deletes all duplicate lines in the list.
177(defalias 'fl-ch-l 'fl-change-log)
178
179
180(defun sql-select-otlne()
181 "This will automatically create a commented outline of a SQL select query to help the user make select queries in SQL code."
182 (interactive)
183 (sql-mode)
184 (move-to-column 0)
185 (insert "SELECT /*@ +IGNORE_CASE */ /* The first comment area should be kept, this is what Meridium uses to specify \"ignore case.\" This line is the \"SELECT\" line. In the SQL Structure Spreadsheet, select fields using the \"Field ID\" column which is column \"D\" separate multiple fields with a comma. For example, \"[Table1].[Field1], [Table2].[Field2].\"*/\n\nFROM /* This is the \"FROM\" line. Here you should enter the \"Table ID\" field from the table(s) that the data fields that you have selected are from. For example,\"FROM [Table1]\". If you are using data fields from more than one table, you need to join them. You can join them using an official join link, or where two fields are equal. For example, joining the fields with an official link would look like this. \"FROM [Table1] JOIN_SUCC [Table2] ON {MIR_HasTable1}.\" The \"JOIN_SUCC\" means that the table \"Table1\" is the successor table to the Table2 table. To join tables via equal data, you can use something like this. \"FROM [Table1] JOIN [Table2] ON [Table1].[Field1] = [Table2].[Field1].\" This would link table 1 with Table2 table where Field1 for Table1 table equals the Field1 in Table2. There is no direct official link between these two tables, but using this method you can link them.*/\n\nWHERE /* This is the \"WHERE\" line. This is quite possibly the most complicated and important line in the query. Here, you can give criteria for your selection. For example, \"WHERE [Table1].[Field1] = 'Kansas City' \" would select all data fields where Field1 Table1 analysis equals \"Kansas City.\" Where clauses can get extremely complicated. See a SQL tutorial for more information.*/\n\nORDER BY /* This is the \"ORDER BY\" line. This determines how the data is presented in the query return.For example, the phrase \"ORDER BY [Table1].[Field1] Asc. Will sort the query results by Field1 in ascending order. In Contrast, the line \"ORDER BY [Table1].[Field1] Desc would sort it by the same field in descending order. You can order by several groups. The first fields that you use will be sorted before next fields and so on. To do this, simply separate the \"ORDER BY\" statements with commas. For example \"ORDER BY [Table1][Field1] Asc,[Table1][Field2] Asc,[Table1][Field3] Asc,[Table1][Field4] Asc.\"*/\n\n/*This is just meant as an overview. For more information, view a SQL tutorial.*/")
186 (backward-paragraph 5))
187(defalias 's-slct-o 'sql-select-otlne)
188
189
190(defun sql-update-otlne()
191 "This is meant as an example of an update query. It will automatically create a commented outline of a SQL update query"
192 (interactive)
193 (sql-mode)
194 (move-to-column 0)
195 (insert "UPDATE /* This is the update clause. You need to select exactly one table to update. You can only update one table at a time. For example. \"UPDATE [Table1]\". */\n\nSET /* This is the set clause. Here you set what data you would like to change. You can change multiple data fields at once or just one data field at a time. For example \"SET [Table1].[Field1] = '01/01/18 12:00 AM', [Table2].[Field2] = '01/01/19 12:00 AM' \".*/\n\nWhere /* This is the where clause. Just like the select query, this is where you select exactly which records you would like to update. If you completely ommitted this clause, it would update every record in the entire table. Update queries are like weapons, only point them at data that you wish to update. I suggest that you make a select query with the fields and table that you wish to update with the same \"WHERE\" clause to see exactly which data records you will be updating. An example of a where clause is \"WHERE [Table1].[Field1] IN ('69840567', '69840575', '69840589')\"*/\n\n/*This is just meant as an overview. For more information, view a SQL tutorial.*/")
196 (backward-paragraph 4))
197(defalias 's-updt-o 'sql-update-otlne)
198
199(defun sql-select()
200 "Helps you create a SQL select query."
201 (interactive)
202 (sql-mode) ;; Turns SQL mode on for proper highlighting.
203 (end-of-buffer)
204 (if (> (current-column) 0)
205 (insert "\n"))
206 (let (select
207 from ;; Elisp "let" statement. Keeps variables local.
208 where
209 orderBy
210 pos
211 pos2) ;; The next 4 lines get the criteria from the user for making the query.
212 (setq select (read-from-minibuffer "Enter the data fields that you would like to have in your \"SELECT\" clause: "))
213 (setq from (read-from-minibuffer "Enter the data tables and/or joins/links that you would like to have in your \"FROM\" clause: "))
214 (setq where (read-from-minibuffer "Enter the criteria for your \"WHERE\" clause: "))
215 (setq orderBy (read-from-minibuffer "Enter the criteria for your \"Order By\" clause: "))
216 (end-of-line)
217 (insert "\n")
218 (setq pos (point))
219 (insert "SELECT /*@ +IGNORE_CASE */ " select "\n") ;; This line and the rest of the defun is used to print out the query.
220 (insert "FROM " from "\n")
221 (if (not (string= where "")) ;; This is an "IF" statement, if the "WHERE" clause is not being used, the defun will not print out anything for it.
222 (insert "WHERE " where "\n"))
223 (if (not (string= orderBy "")) ;; This is an "IF" statement, if the "ORDER BY" clause is not being used, the defun will not print out anything for it.
224 (insert "ORDER BY " orderBy "\n"))
225 (setq pos2 (point))
226 (copy-region-as-kill pos pos2))) ;; Copies the query.
227(defalias 's-slct 'sql-select)
228
229(defun sql-update()
230 "Helps you create a SQL UPDATE query and creates a SQL select query with the same criteria.."
231 (interactive)
232 (sql-mode) ;; Turns SQL mode on for proper highlighting.
233 (end-of-buffer)
234 (if (> (current-column) 0)
235 (insert "\n"))
236 (let (update
237 set ;; Elisp "let" statement. Keeps variables local.
238 where
239 select
240 pos
241 pos2) ;; The next 4 lines get the criteria from the user for making the query.
242 (setq update (read-from-minibuffer "Enter the data table that you are going to update: "))
243 (setq set (read-from-minibuffer "Enter the data fields that you wish to update with the data that you would like to set it to: "))
244 (setq where (read-from-minibuffer "Enter the criteria for your \"WHERE\" clause: "))
245 (end-of-line)
246 (insert "\n")
247 (setq pos (point))
248 (insert set)
249 (goto-char pos)
250 (while (search-forward-regexp " = [-_'A-Za-z ,0-9]*\\[" nil t)
251 (replace-match ", [" nil))
252 (while (search-forward-regexp " = [-_'A-Za-z ,0-9]*$" nil t)
253 (replace-match "" nil))
254 (end-of-line)
255 (setq pos2 (point))
256 (setq select (buffer-substring-no-properties pos pos2))
257 (delete-region pos pos2)
258 (goto-char pos)
259 (insert "SELECT " select "\n")
260 (insert "FROM " update "\n")
261 (if (not (string= where "")) ;; This is an "IF" statement, if the "WHERE" clause is not being used, the defun will not print out anything for it.
262 (insert "WHERE " where "\n\n\n")
263 (insert "\n\n"))
264 (insert "UPDATE " update "\n") ;; This line and the rest of the defun is used to print out the query.
265 (insert "SET " set "\n")
266 (if (not (string= where "")) ;; This is an "IF" statement, if the "WHERE" clause is not being used, the defun will not print out anything for it.
267 (insert "WHERE " where "\n"))
268 (setq pos2 (point)))) ;; Copies the query.
269(defalias 's-updt 'sql-update)
270
271(defun auto-lkorlk()
272 "Generates a \"LIKE OR LIKE\" expression to create a series of \"LIKES\" in a SQL \"WHERE\" clause. "
273 (interactive)
274 (beginning-of-buffer) ;; Insures that the function starts at the beginning of the buffer.
275 (setq field (read-from-minibuffer "Enter the SQL data field: ")) ;; Prompts the user for the data field to use with the "LIKE" statements.
276 (while (search-forward-regexp "^" nil t) ;;This while loop searches for the beginning of each line and adds the data field that the user entered plus " LIKE('%"
277 (replace-match (concat field " LIKE('%") nil))
278 (end-of-buffer) ;; These next 5 lines are used to erase the end line which at this point is garbage.
279 (setq pos (point))
280 (beginning-of-line)
281 (setq pos2 (point))
282 (kill-region pos2 pos)
283 (beginning-of-buffer)
284 (while (search-forward-regexp "\n" nil t) ;; This while loop replace every new line character with "%') OR ".
285 (replace-match "%') OR " nil))
286 (end-of-buffer) ;; The next 5 lines are used to erase trailing garbage, thereby completing the "LIKE OR LIKE" statement.
287 (setq pos (point))
288 (backward-char 4)
289 (setq pos2 (point))
290 (kill-region pos2 pos))
291(defalias 'a-lk 'auto-lkorlk)
292
293(defun table2csv()
294 "This will convert Emacs text tables to a CSV style to copy and paste them into Excel, Libre Office Calc, Gnumeric or any other spreadsheet. This assumes the default table style. It will not work with any other style. This also assumes that \"|\" is nowhere in the body of your table."
295 (interactive)
296 (let (delimiter)
297 (setq delimiter (read-from-minibuffer "Enter the column delimiter that you would like to use: ")) ;;The user can choose any delimiter they wish.
298 (beginning-of-buffer)
299 (while (search-forward-regexp "^.*\\(\\+-*\\)*-*\\+\n" nil t) ;;Erases the row delimiter of the table.
300 (replace-match "" nil))
301 (beginning-of-buffer)
302 (while (search-forward-regexp " *| *" nil t) ;;Replaces the common column delimter "|" and the forward and trailing whitespaces with the column delimiter that the user chose.
303 (replace-match delimiter nil ))
304 (beginning-of-buffer)
305 (while (re-search-forward (concat "^" delimiter) nil t) ;;Replaces the beginning character (which should be the chosen delimiter) with nothing.
306 (replace-match "" nil)
307 (next-line))
308 (beginning-of-buffer)
309 (while (re-search-forward (concat delimiter "$") nil t) ;;Replaces the ending character (which should be the chosen delimiter) with nothing.)
310 (replace-match "" nil))))
311
312(defalias 't2csv 'table2csv)
313
314
315(defun tl-erase()
316 (interactive)
317 "This will erase the marked lines in the task lists automatically. Erases the entire lines of tasks that are done and erases the \"new\" and \"worked on\" marks."
318 (beginning-of-buffer)
319 (while (search-forward-regexp ".*XXX+\n\\|YYY+" nil t)
320 (replace-match "" nil))
321 (beginning-of-buffer)
322 (while (search-forward-regexp "[ ][0-9\\.]+[ ][Hh]\\(ours\\|our\\)" nil t)
323 (replace-match "" nil))
324 (tl-highlight))
325
326
327(defalias 'tle 'tl-erase)
328
329(defun auto-task-list() ;; Generates a daily task list based on the previous day's task list.
330 "Generates your task list. Erases the numbers so that you can reaffirm the hiarchy of tasks, and highlights tasks that are done, are partially done, and have notes in them. Will prompt you for the previous and current work days before it runs."
331 (interactive)
332 (let
333 (prev
334 cur
335 curTime
336 fileExt
337 taskDirectory)
338 (setq fileExt "Tasks.txt")
339 (setq taskDirectory "c:/Users/GMRider/Documents/eFiles/tasks/")
340 (setq prev (read-from-minibuffer "Enter the previous work day's date in the YYYYMMDD format: "))
341 (setq cur (read-from-minibuffer "Enter the current day's date in the YYYMMDD format: "))
342 (setq curTime (read-from-minibuffer "Enter the time that the current work day started: "))
343 (copy-file (concat taskDirectory prev fileExt) (concat taskDirectory cur fileExt))
344 (find-file (concat taskDirectory cur fileExt))
345 (beginning-of-buffer)
346 (while (search-forward-regexp "^[0-9.]*. \\|^[0-9.] *" nil t)
347 (replace-match "" nil))
348 (beginning-of-buffer)
349 (while (search-forward-regexp "^[0-9]+[A-Za-z] " nil t)
350 (replace-match "~~" nil))
351 (beginning-of-buffer)
352 (tl-highlight)
353 (forward-paragraph 2)
354 (kill-paragraph 5)
355 (end-of-buffer)
356 (insert (concat "\n " curTime " -\n"))
357 (beginning-of-buffer)))
358
359(defalias 'a-tsk-l 'auto-task-list)
360
361
362(defun work-log-create()
363 (interactive)
364 (let (
365 pos1
366 pos2
367 pos3
368 pos4
369 hrsDay)
370 (beginning-of-buffer)
371 (setq pos3 (point))
372 (forward-paragraph 2)
373 (next-line)
374 (end-of-buffer)
375 (setq pos4 (point))
376 ;;(insert "*************pos4***************\n")
377 (insert "\n~~~~~~~~~~Work Log For The Day~~~~~~~~~~~\n\n")
378 (beginning-of-buffer)
379 (while (and (search-forward-regexp "XXX+\\|YYY+\\|\\^\\^\\^\\^\\^+\\|\\*\\*\\*\\*+" nil t) (< pos3 pos4)) ;;This while lop creates the work log.
380 (beginning-of-line)
381 (setq pos1 (point))
382 (end-of-line)
383 (setq pos2 (point))
384 (setq pos3 (point))
385 (end-of-buffer)
386 (insert "\n" (buffer-substring-no-properties pos1 pos2))
387 (goto-char pos3))
388 (backward-paragraph)
389 (while (search-forward-regexp "XXX+\\|YYY+" nil t) ;;The following while loops erase the marks on the tasks that are not needed.
390 (replace-match "" nil))
391 (backward-paragraph)
392 (while (search-forward-regexp "^[0-9]. \\|^[0-9] " nil t)
393 (replace-match "" nil))
394 (backward-paragraph)
395 (while (search-forward-regexp "1[ ][Hh]ours" nil t) ;;This an the next while loop format the numbers and hours for uniformity.
396 (replace-match "1 Hour" nil))
397 (backward-paragraph)
398 (while (search-forward-regexp "[Hh]our" nil t)
399 (replace-match "Hour" nil))
400 (end-of-buffer)
401 (setq pos2 (point))
402 ;;(insert "this is a test 2*")
403 (insert "\n\n\n")
404 (setq pos3 (point))
405 ;;(insert "this is a test 3*")
406 (beginning-of-line)
407 (backward-paragraph 2)
408 (while (and (search-forward-regexp "[0-9\\.]+[ ][Hh]our" nil t) (< pos2 pos3)) ;;This while loop and the rest of the defun creates a an Emacs Lisp expression that caluclates the hours worked in the day and prints it at the bottom of the buffer.
409 (backward-word)
410 (setq pos2 (point))
411 (search-backward-regexp " [0-9\\.]+[ ]")
412 (forward-char)
413 (setq pos1 (point))
414 (end-of-line)
415 (setq pos4 (point))
416 ;;(insert " 4**")
417 (end-of-buffer)
418 (insert "\n" (buffer-substring-no-properties pos1 pos2))
419 (goto-char pos4))
420 (end-of-buffer)
421 (backward-paragraph)
422 (insert "(+")
423 (whitespace-cleanup)
424 (while (search-forward-regexp "\n" nil t)
425 (replace-match " " nil))
426 (end-of-line)
427 (insert ")")
428 (setq hrsDay (eval-last-sexp nil))
429 (insert (concat "\n\n\n" (number-to-string hrsDay) " Hours Worked On This Day"))
430 (tl-highlight)
431 (save-buffer)))
432
433(defalias 'wlc 'work-log-create)
434
435(defun tl-highlight()
436 (interactive)
437 (unhighlight-regexp ".*XXX+$")
438 (unhighlight-regexp ".*YYY+$")
439 (unhighlight-regexp ".+NNN$")
440 (unhighlight-regexp ".*\\^\\^\\^\\^\\^+")
441 (unhighlight-regexp ".*\\*\\*\\*\\*+")
442 (unhighlight-regexp ".*\\[.*")
443 (unhighlight-regexp ".*(.*")
444 (highlight-regexp ".*XXX+$" 'hi-red-b)
445 (highlight-regexp ".*YYY+$" 'hi-yellow)
446 (highlight-regexp ".+NNN$" 'hi-pink)
447 (highlight-regexp ".*\\^\\^\\^\\^\\^+" 'hi-blue)
448 (highlight-regexp ".*\\*\\*\\*\\*+" 'hi-green)
449 (highlight-regexp ".*\\[.*" 'hi-red-b)
450 (highlight-regexp ".*(.*" 'hi-green-b))
451
452
453(defalias 'tlh 'tl-highlight)
454
455(defun tl-hours(hours)
456 (interactive "sEnter The Number Of Hours Worked On This Task: ")
457 (let (markChar)
458 (end-of-line)
459 (if (not (string= hours ""))
460 (insert (concat " " hours " Hours")))
461 (setq markChar (read-char-exclusive "Enter The Character To Mark The Line With \"X\" If The Task Is Done And \"Y\" If The Task Is Not Done."))
462 (tl-mark-line markChar)))
463
464(defalias 'tlhrs 'tl-hours)
465
466
467
468(defun fl-type-check()
469 "This will check the numbers for all FL types in the functional location categorization spreadsheet. This is meant to be called over and over again via macro."
470 (interactive)
471 (let (pos1
472 pos2
473 numMatch)
474 (search-forward-regexp "^[0-9]+$") ;;Searches for any numbers at the beginning of a line.
475 (setq pos1 (point)) ;; Records the position of pos1 as (point)
476 (search-forward-regexp "^[0-9]+$") ;;Searches for any number(s) a the beginning of a line.
477 (setq pos2 (point)) ;; Records the position of pos2 as (point)
478 (setq numMatch (number-to-string (count-matches "[A-Za-z]\\{4\\}[0-9]\\{3\\}-[A-Za-z0-9]\\{4\\}-[A-Za-z]\\{2\\}-[0-9]\\{2\\}" pos1 pos2 nil))) ;; Counts the matches for the regular expression between the two points. And records the value of matches into numMatch.
479 (goto-char pos1) ;; Goes back to position one.
480 (end-of-line) ;; Goes to the end of the line
481 (insert (concat "\t" numMatch)) ;; Inserts a tab and then numMatch.
482 (goto-char pos2)
483 (beginning-of-line))) ;; Goes back to pos2.
484
485(defalias 'fl-t-ch 'fl-type-check)
486
487;; The next lines make sure that all of the functions are put in as "Safe" functions.
488
489(put 'auto-in-function 'safe-function t)
490(put 'auto-lkorlk 'safe-function t)
491(put 'auto-new-line 'safe-function t)
492(put 'auto-query-copy 'safe-function t)
493(put 'auto-task-list 'safe-function t)
494(put 'fill-to-end120 'safe-function t)
495(put 'fill-to-end200 'safe-function t)
496(put 'fill-to-end80 'safe-function t)
497(put 'fl-change-log 'safe-function t)
498(put 'fl-type-check 'safe-function 't)
499(put 'prlRes 'safe-function t)
500(put 'sql-select 'safe-function t)
501(put 'sql-select-otlne 'safe-function t)
502(put 'sql-update 'safe-function t)
503(put 'sql-update-otlne 'safe-function t)
504(put 'table2csv 'safe-function t)
505(put 'tl-erase 'safe-function t)
506(put 'tl-highlight 'safe-function t)
507(put 'tl-hours 'safe-function t)
508(put 'tl-mark-line 'safe-function t)
509(put 'work-log-create 'safe-function t)
510
511
512
513
514;;find duplicate lines. I didn't write this one
515
516(defun find-duplicate-lines (&optional insertp interp)
517 (interactive "i\np")
518 (let ((max-pon (line-number-at-pos (point-max)))
519 (gather-dups))
520 (while (< (line-number-at-pos) max-pon) (= (forward-line) 0)
521 (let ((this-line (buffer-substring-no-properties (line-beginning-position 1) (line-end-position 1)))
522 (next-line (buffer-substring-no-properties (line-beginning-position 2) (line-end-position 2))))
523 (when (equal this-line next-line) (setq gather-dups (cons this-line gather-dups)))))
524 (if (or insertp interp)
525 (save-excursion (new-line) (princ gather-dups (current-buffer)))
526 gather-dups)))
527
528
529;; Custom keybindings
530
531(global-set-key (kbd "C-b") 'auto-query-copy)
532(global-set-key (kbd "C-c s") 'replace-string)
533(global-set-key (kbd "C-x r 1") 'fill-to-end120)
534(global-set-key (kbd "C-x r 2") 'fill-to-end200)
535(global-set-key (kbd "C-x r 8") 'fill-to-end80)
536(global-set-key (kbd "C-;") 'tl-hours)
537(global-set-key (kbd "C-x r e") 'replace-regexp)
538(global-set-key (kbd "C-x r h") 'highlight-regexp)
539(global-set-key (kbd "C-x r u") 'unhighlight-regexp)
540;;(global-set-key (kbd "M-j") 'backward-char)
541(global-set-key (kbd "M-h") 'backward-char)
542(global-set-key (kbd "M-b") 'ergoemacs-beginning-or-end-of-buffer)
543;;(global-set-key (kbd "M-n") 'ergoemacs-beginning-or-end-of-buffer)
544(global-set-key (kbd "M->") 'compare-windows)
545(define-key text-mode-map (kbd "TAB") 'self-insert-command) ;; This makes sure that the <tab> key only inserts a tab in text mode.
546
547;;custom hooks
548(add-hook 'before-save-hook 'whitespace-cleanup)
549
550
551(defun turn-on-visual-line-mode-in-txt()
552 (when (and (buffer-file-name) (string-match ".txt$" (buffer-file-name)))
553 (turn-on-visual-line-mode)))
554(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
555
556
557(defun my-c++-mode-hook ()
558 ;;(setq c-basic-offset 4)
559 (setq c-basic-indent 2)
560 (c-set-offset 'substatement-open 0)
561 (setq indent-tabs-mode nil))
562(add-hook 'c++-mode-hook 'my-c++-mode-hook)
563
564(defun task-list-hook()
565 (when (and (buffer-file-name) (string-match "Tasks.txt$" (buffer-file-name)))
566 (tl-highlight)))
567
568(add-hook 'text-mode-hook 'task-list-hook)
569
570;;Custom Additions To C++ mode
571
572(add-to-list 'auto-mode-alist '("\\.cs\\'" . c++-mode))
573
574;; Custom backup saving.
575
576(setq backup-by-copying t)
577(setq backup-directory-alist '(("." . ".~")))
578
579;;ergo emacs mode You must download it and install it via the instructions on https://jpace.wordpress.com/2011/12/30/ergonomic-emacs-keybindings/
580
581;;(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "us") ;; US
582(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "dv") ;; For Dvorak layout
583;; load ErgoEmacs keybinding
584(load "~/.emacs.d/ergoemacs-mode-master/ergoemacs-mode.el")
585
586;; turn on minor mode ergoemacs-mode
587(setq ergoemacs-theme nil)
588(ergoemacs-mode 1)
589
590;; Load Visual Basic Mode
591
592(load "~/.emacs.d/visual-basic-mode/visual-basic-mode.el")
593
594;; Alias For Visual Basic Mode
595
596(defalias 'v-b-m 'visual-basic-mode)
597
598
599;;Start Auto Task List
600(auto-task-list)