Windows 10: Farbe inaktiver (und aktiver) Fenster

Windows 10 hatte bis irgendwann das Problem, dass man die Farbe des aktiven Fensters nicht einstellen konnte. Das wurde zwar gefixt, aber den Weg will ich trotzdem nochmal vorstellen, indem ich auf dieses Video verweise: https://www.youtube.com/watch?v=sH8KC-keC5U. Kurz gesagt: c:\Windows\Resources\Themes\ aero kopieren nach windows und Dateien anpassen.

Ab irgendeinem Windows Patch wurde es möglich die “Akzentfarbe” zu ändern, mit dem Effekt, dass alle inaktiven Fenster wieder mit einer weißen Rahmenfarbe dargestellt werden. *seufz* Auch das kann man anpassen. Wie das geht sagt dieser Beitrag: http://www.ghacks.net/2015/11/29/change-the-color-of-inactive-windows-in-windows-10/. Kurz gesagt: Registry-Hacks.

Irgendwann geht es vielleicht mal auch mit Dialogen.

Advertisements

Updated mapserver-mode for editing UMN Mapserver files in Emacs

tl;dr Updated mapserver-mode for Emacs to help editing UMN Mapserver map-files is available at https://github.com/AxxL/mapserver-emacs-mode

I’ve updated the mapserver-mode provided by Hal Mueller. His last change on the code dates 2 years ago, the file was created 10 years ago. Using the mode with the current Mapserver version 6.4.1 was possible but a lot of keywords were not highlighted.

The code seems to follow the Mode Tutorial by Scott Andrew Borton. I left it that way and made some adjustments to the regular expressions. The way to do this is explained in the Mode Tutorial. You have to use the regexp-opt function.

My working files are at the tmp folder.

“keywords_level1_objects.txt” lists the Keywords that are Objects in Mapservers sense. All that are ended with the END keyword.

“keywords_level2_variables.txt” lists the variables that you can use in objects.

“keywords_level3-constants.txt” lists values that you can set to variables.

“regexp-opt-umnmapserver.el” is the file where I copy & paste the lists and start the regexp-opt function. After this I copy & paste the result (from the *Messages* buffer) in my mapserver-mode.el. It is a raw handmade workflow but it’s OK.

“todo_web_object_metadata.txt” lists the metadata for OWS services. They are not highlighted yet.

“issues.org” contains my notes for Todos and issues.

Using Emacs org-mode for a tipping game

I have to give credits for this solution to my colleague Andreas, who wrote the Lisp Code and the Org-Mode table formula. Thanks Andreas.

tl;dr Using Emacs org-mode for a tipping game. Tips are written into an org-mode table. With Lisp and table-formulas it’s easy to count and sum the points, each player got.

Step 1: Rules of the game.

  • Tendency: 2 Points (also when Draw),
  • Goal Difference: 3 Points,
  • Result: 4 Points (also when Draw).

Step 2: Creating the table.

|  1 | DATUM              | G | PARTIE                   | ERG | AXEL | Pnt | ANDR | Pnt |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  2 | WELTMEISTERTIPP    |   |                          | ??? |  Bra |     |  Por |     |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  3 | DO 12.6. 22.00 Uhr | A | Brasilien - Kroatien     | 3-1 |  2-0 |     |  2-1 |     |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  4 | FR 13.6. 18.00 Uhr | A | Mexiko - Kamerun         | 1-0 |  1-0 |     |  2-1 |     |
|  5 | FR 13.6. 21.00 Uhr | B | Spanien - Niederlande    | 1-5 |  1-1 |     |  2-1 |     |
|  6 | FR 13.6. 24.00 Uhr | B | Chile - Australien       | 3-1 |  0-0 |     |  2-1 |     |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  7 | SA 14.6. 18.00 Uhr | C | Kolumbien - Griechenland | 3-0 |  2-0 |     |  2-1 |     |
|  8 | SA 14.6. 21.00 Uhr | D | Uruguay - Costa Rica     | 1-3 |  1-0 |     |  2-1 |     |
|  9 | SA 14.6. 24.00 Uhr | D | England - Italien        | 1-2 |  0-1 |     |  1-2 |     |
| 10 | SA 14.6. 27!!! Uhr | C | Elfenbeinküste - Japan   | 2-1 |  0-2 |     |  2-1 |     |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
| 11 | SUMME              |   |                          |     |      |     |      |     |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  1 | 2                  | 3 | 4                        |   5 |    6 |   7 |    8 |   9 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|

This is a simple table in org-mode containing the columns for the game information (date and time, group, game itself), the column for the result and then the tips by me and Andreas. After each column containing the tips, I’ve included a column for the points, each from us gets for his tip (named “Pnt”). These columns are filled when I run the function below.

I’ve added a column containing the row-numbers at the left and a row containing the column-numbers at the bottom. We need this information for the org-table formula later (org-table-current-column and org-table-current-dline)

Step 3: The calculation logic

This lisp-code gets the actual result of the game (act) and the bet value (erg) to compare them according to the rules above. It calculates either 4, 3, 2 or 0.


: ;; Tipprunde
: (defun wm-calc-pts (act erg)
: (if (or (not (string-match "-" act))
: (not (string-match "-" erg)))
: 0
: (let ((a (string-to-number (car (split-string act "-"))))
: (b (string-to-number (cadr (split-string act "-"))))
: (x (string-to-number (car (split-string erg "-"))))
: (y (string-to-number (cadr (split-string erg "-")))))
: (cond
: ((and (= a x) (= b y)) 4)
: ((= (- b a) (- y x)) 3)
: ((or
: (and (> a b) (> x y))
: (and (< a b) (< x y))
: (and (= a b) (= x y))) 2)
: (t 0)))))

Step 4: The Table Function

The table function is placed below the table. It does two things:

– Use the lisp function wm-calc-pts to calculate the points for each bet.
– Sum the points and write them to a cell.

: #+TBLFM: $7='(wm-calc-pts $5 $6)::@11$7=vsum(@4..@-1)

The two calulcations are divided by the “::” mark.

$7='(wm-calc-pts $5 $6) uses column 7 (Pnt for player Axel) and fills it with the results from the wm-calc-pts function. The input parameters for this function is filled with the values from column $5 (the actual result, act) and column $7 (the bet from player Axel, erg).

@11$7=vsum(@4..@-1) fills the cell at row 11 and column 7 (for player Axel) with the sum from the column, beginning at line 4 and ending at line 10 (11 minus 1).

This is done for each player, so we added an additional stack of formulars for player Andr: $9='(wm-calc-pts $5 $8)::@11$9=vsum(@2..@-1)

The whole formular looks like this:

#+TBLFM: $7='(wm-calc-pts $5 $6)::@11$7=vsum(@2..@-1)::$9='(wm-calc-pts $5 $8)::@11$9=vsum(@2..@-1)

Step 5: Executing the function

Executing the function is easy. Place your cursor inside the line and hit C-c C-c. The values will be calculated and the cells are filled with the calculated values.

|  1 | DATUM              | G | PARTIE                   | ERG | AXEL | Pnt | ANDR | Pnt |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  2 | WELTMEISTERTIPP    |   |                          | ??? |  Bra |   0 |  Por |   0 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  3 | DO 12.6. 22.00 Uhr | A | Brasilien - Kroatien     | 3-1 |  2-0 |   3 |  2-1 |   2 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  4 | FR 13.6. 18.00 Uhr | A | Mexiko - Kamerun         | 1-0 |  1-0 |   4 |  2-1 |   3 |
|  5 | FR 13.6. 21.00 Uhr | B | Spanien - Niederlande    | 1-5 |  1-1 |   0 |  2-1 |   0 |
|  6 | FR 13.6. 24.00 Uhr | B | Chile - Australien       | 3-1 |  0-0 |   0 |  2-1 |   2 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  7 | SA 14.6. 18.00 Uhr | C | Kolumbien - Griechenland | 3-0 |  2-0 |   2 |  2-1 |   2 |
|  8 | SA 14.6. 21.00 Uhr | D | Uruguay - Costa Rica     | 1-3 |  1-0 |   0 |  2-1 |   0 |
|  9 | SA 14.6. 24.00 Uhr | D | England - Italien        | 1-2 |  0-1 |   3 |  1-2 |   4 |
| 10 | SA 14.6. 27!!! Uhr | C | Elfenbeinküste - Japan   | 2-1 |  0-2 |   0 |  2-1 |   4 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
| 11 | SUMME              |   |                          |     |      |  12 |      |  17 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
|  1 | 2                  | 3 | 4                        |   5 |    6 |   0 |    8 |   0 |
|----+--------------------+---+--------------------------+-----+------+-----+------+-----|
#+TBLFM: $7='(wm-calc-pts $5 $6)::@11$7=vsum(@2..@-1)::$9='(wm-calc-pts $5 $8)::@11$9=vsum(@2..@-1)

Making GNU Emacs play well on Microsoft Windows 7 (my additions to Sacha Chuas post)

Some time ago Sacha Chua posted a blog entry called Making GNU Emacs play well on Microsoft Windows 7. It offers a quick introduction how easy it is to install Emacs on Windows systems and you can follow that guideline. My system differs a bit from that and I want to show you on where and why.

  1. My path where I extract emacs is C:/bin/edit/emacs. I don’t like to put things directly under C:/ (except for my bin directory ^^) and I guess it’s not the best way to handle Windows. It would be more correct to put it under C:/Program Files(x86) but I don’t have the rights to create files there (which might be the reason why it’s better to put it there) so I decided to create a bin directory under C:/ where I put some applications. Also c:/Users/axxllence/bin/edit/ might work if you are the only user using Emacs or you have trouble creating directories under C:/.
  2. Start -> environment should list “Environment variables for this user”
  3. My home is: %HOME%=C:/Users/axxllence/Documents/home. I backup my Documents folder. I don’t backup every stuff under C:/Users/axxllence/ nor the AppData directory.
  4. OK
  5. My working directory in the shortcut is of course: %HOME%

One handy advice: If you want to create a file or directory in Explorer with a dot in front, you might have trouble doing it. Put a dot after the name and it works. (.emacs.d.). Weird but works. You can also use Emacs and M-x make-directory. Or you buy the essential .

That’s all. Not much difference. Have fun.

Emacs snippet: lookup / search wikipedia, google or any other side

This small snippet looks up a the current word or region in Wikipedia. If the cursor is before a word, it grabs the word. If you have marked a region, it grabs that. The function opens the search site in Wikipedia to lookup your searchterm.

I’ve used the sample from from Xah Lees page (http://ergoemacs.org/emacs/elisp_idioms.html).


;; ,----
;; | Wikipedia Lookup
;; `----
;; Looks up current word in Wikipedia in a browser. If a region is
;; active (a phrase), lookup hat phrase.
;; http://ergoemacs.org/emacs/elisp_idioms.html
(defun wikipedia-lookup ()
(interactive)
(let (myWord myUrl)
(setq myWord
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(thing-at-point 'symbol)))
(setq myUrl
(concat "http://de.wikipedia.org/wiki/Special:Search?search=" myWord))
(browse-url myUrl)))

You can do that for some other sites. Simply set the my Url to a different location:

I’ll give you the example for the emacs wiki. You have to put a ” ” space after the URL parameter “site:emacswiki.org ”


(defun emacswiki-lookup ()
(interactive)
(let (myWord myUrl)
(setq myWord
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(thing-at-point 'symbol)))
(setq myUrl
(concat "http://www.google.de/search?q=site:emacswiki.org " myWord))
(browse-url myUrl)))

If you define more lookups an interactive function would be nice which asks for the specific lookup:

  • [e]macswiki
  • [g]oogle
  • [l]eo
  • [w]ikipedia

Don’t know how to do that. 😉

Emacs navigating {parantheses}

Writing a lot of JavaScript I want to navigate to the end of a method, object or similar. Normally I want to go from the beginning parenthesis “{” to the ending one “}”. The font-lock-mode highlights the opposite parenthesis or the region (if it’s outside the visible screen).

Navigation goes quick with C-M-n or C-M-p.

See the Emacs wiki: http://www.emacswiki.org/emacs/NavigatingParentheses

C-h k C-M-n:

C-M-n runs the command forward-list, which is an interactive compiled Lisp
function in `lisp.el’.

It is bound to C-M-n.

(forward-list &optional ARG)

Move forward across one balanced group of parentheses.
With ARG, do it that many times.
Negative arg -N means move backward across N groups of parentheses.
This command assumes point is not in a string or comment.

C-h k C-M-p:

C-M-p runs the command backward-list, which is an interactive compiled Lisp
function in `lisp.el’.

It is bound to C-M-p.

(backward-list &optional ARG)

Move backward across one balanced group of parentheses.
With ARG, do it that many times.
Negative arg -N means move forward across N groups of parentheses.
This command assumes point is not in a string or comment.